How to get the id's of html element of html document in c# using html agility pack?

c# html-agility-pack

Question

I have something like this

<div class='mainclass subclass1' quest-id='123'> </div>
<div class='mainclass subclass2' quest-id='234'> </div>
<input quest-id='3236'> </input>
<textarea quest-id='256'> </textarea>

I want the quest-d of all div which belongs to class named subclass1, subclass2 and quest-id of all input and textarea. How can i do it using html agility pack in c#?

and i have c# code like this:

HtmlDocument document = new HtmlDocument();
document.LoadHtml(obj.NewPage.Content);

HtmlNode htmlRootElement = document.DocumentNode.SelectSingleNode("/html");
HtmlNode bodyElement = htmlRootElement.SelectSingleNode("body");

i dont know how to proceed

1
2
4/3/2014 5:48:14 AM

Popular Answer

 string id = div.GetAttributeValue("id", "").ToString();
 string name= div.GetAttributeValue("name", "").ToString();
0
8/26/2014 8:52:14 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