How to get div by class in HtmlAgilityPack?

c# html-agility-pack windows-phone-8

Question

I'm using this instruction, but I'm having an issue since I'm not sure how tohtmlNode by the class name

HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
htmlDoc.OptionFixNestedTags = true;
htmlDoc.LoadHtml(e.Result);
HtmlNode divContainer = htmlDoc.GetElementbyId("directoryItems");//My problem here,I want to get by class name html
if (divContainer != null)
{
     HtmlNodeCollection nodes = divContainer.SelectNodes("//table/tr");
     ....
}
1
2
4/15/2014 9:52:41 AM

Popular Answer

Do this:

HtmlNodeCollection divContainer = htmlDoc.DocumentNode.SelectNodes("//div[@class='myClass']");

this will produce a group of div nodes with the value class="myClass".

2
4/15/2014 9:44:12 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