Skip to content Skip to sidebar Skip to footer

Html Agility Pack, Iteration On Table Node Not Working

I have the following code which should iterate through all the 's in just one table (the fourth one on the page). foreach (HtmlNode table in doc.DocumentNode.SelectNodes(

Solution 1:

You need to add single dot (.) at the beginning of the XPath to make it recognized as relative path (in this case, relative to current table) :

foreach (var td in table.SelectNodes(".//td"))
{
   Console.WriteLine(td.InnerText);
}

Post a Comment for "Html Agility Pack, Iteration On Table Node Not Working"