HTML Agility Pack, C#, parsing HTML page

c# html html-agility-pack

Question

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?

1
3
5/23/2017 12:19:32 PM

Accepted Answer

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.

6
2/12/2010 8:21:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow