HtmlAgilityPack can't find element


Question

I need to parse a site and I know where to find the element I'm searching: it's a span with class="metadata_with_icon-tags-primary_tag".

My C# code:

var page = new HtmlWeb().Load(url).DocumentNode.Descendants("span").Where(d => d.Attributes.Contains("class") && d.Attributes["class"].Value.Contains("metadata_with_icon-tags-primary_tag"));

Item that I need: enter image description here

Popular Answer

To get your span with class="metadata_with_icon-tags-primary_tag":

HtmlNode node = htmlDoc.DocumentNode.SelectSingleNode("//span[@class='metadata_with_icon-tags-primary_tag']");




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