开发者

C#, parsing HTML page, using HTML Agility Pack

开发者 https://www.devze.com 2022-12-19 20:58 出处:网络
Following this example, I can find the LI sections. Html Agility Pack - Parsing 开发者_运维技巧<li>

Following this example, I can find the LI sections.

Html Agility Pack - Parsing 开发者_运维技巧<li>

However, I only want the LI items that reside inside the div with an id of "res".

How do I do that?


Something like this:

List facts = new List();
foreach (HtmlNode li in doc.DocumentNode.SelectNodes("//div[@id='res']/li")) {
    facts.Add(li.InnerText);
}
XPath Checker might also help you with future XPath queries.

0

精彩评论

暂无评论...
验证码 换一张
取 消