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

Popular Answer

 string id = div.GetAttributeValue("id", "").ToString();
 string name= div.GetAttributeValue("name", "").ToString();



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why