Using HtmlAgilityPack to pick Divs by class from an HTML page

c# html html-agility-pack

Question

I may choose divs that have an id of "foo" while I'm using C# with HTML Agility Pack.

var foos = from foo in htmlDoc.DocumentNode.Descendants("div")
           where foo.Id == "foo" 
           select foo;

nevertheless, how can I choose divs with the bar class?

1
5
4/16/2010 9:22:16 PM

Accepted Answer

This is how you can utilize XPATH.

//div[@class='bar'] 

or

//*/div[@class='bar']

You may be able to do && as well.foo.Class == "bar" .

9
8/24/2012 6:34:13 AM


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