我使用HtmlAgilityPack。 我想要take(title1和title2仅在Title:part中)或(number1和number2仅在Number:part中)。
<div>
<span class="dark_text">Title:</span>
<a href="linktitle1" title="title1">title1</a>,<a href="link title2" title="title2">title2</a>
</div>
//other part same xml
<div>
<span class="dark_text">Number:</span>
<a href="linknumber1" title="number1">number1</a>,<a href="linknumber2" title="number2">number2</a>
</div>
我试试这段代码:
HtmlNodeCollection summary = doc.DocumentNode.SelectNodes(".//div/a[not(@id)]");
MessageBox.Show(summary.Count.ToString());
for (int i = 0; i < summary.Count; i++)
{
MessageBox.Show(summary[i].InnerText.ToString());
}
但是消息框显示了所有这些(title1,title2,number1,number2)。我不知道只采用一部分类别。
答案 0 :(得分:1)