下面給出的代碼是用於從html頁面讀取段落。它是好的代碼,但如何可以採取一個段落或如果我只保存段落2或5如何只能採摘具體的段落號。閱讀html asp.net C#的特定段落#
public string GetParagraphs(string html, int numberOfParagraphs)
{
const string paragraphSeparator = "</p>";
var paragraphs = html.Split(new[] { paragraphSeparator }, StringSplitOptions.RemoveEmptyEntries);
return string.Join("", paragraphs.Take(numberOfParagraphs).Select(paragraph => paragraph + paragraphSeparator));
}
偉大的....感謝它的工作。 – user5035334