How would I use HTMLAgilityPack to extract the value I want
- by Nai
For the given HTML I want the value of id
<div class="name" id="john-5745844">
<div class="name" id="james-6940673">
UPDATE
This is what I have at the moment
HtmlDocument htmlDoc = new HtmlDocument();
htmlDoc.Load(new StringReader(pageResponse));
HtmlNode root = htmlDoc.DocumentNode;
List<string> anchorTags = new List<string>();
foreach (HtmlNode div in root.SelectNodes("//div[@class='name' and @id]"))
{
HtmlAttribute att = div.Attributes["id"];
Console.WriteLine(att.Value);
}
The error I am getting is at the foreach line stating: Object reference not set to an instance of an object.