Finding node using HTML agility pack

c# html-agility-pack

Question

Here is the google chrome dev tool to get the elment im looking for.

enter image description here

Here are all the different ways I have tried to get the nodes..

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();

            doc.LoadHtml(webObject.Html);

            // HtmlNode footer = doc.DocumentNode.Descendants().SingleOrDefault(y => y. == "boardPickerInner");
            // "//div[@class='boardPickerInner']"
            //var y = (from HtmlNode node in doc.DocumentNode.SelectNodes("//")
            //         where node.InnerText == "boardPickerInner"
            //         select node.InnerHtml);

              HtmlAgilityPack.HtmlNode bodyNode = doc.DocumentNode.SelectSingleNode("//nameAndIcons");

              var xq = doc.DocumentNode.SelectSingleNode("//td[@class='nameAndIcons']");

            var x = doc.DocumentNode.SelectSingleNode("");

            HtmlNode nodes = doc.DocumentNode.SelectSingleNode("//[@class='nameAndIcons']");

            var boards = nodes.SelectNodes("//*[@class='nameAndIcons']");

Can someone explain what I am doing wrong..?

Accepted Answer

It looks like you have multiple span elements with class="nameAndIcons". So in order to get them all you could use the SelectNodes function:

var nodes = doc.DocumentNode.SelectNodes("//span[@class='nameAndIcons'"])



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