I believe I have a similar problem, as demonstrated thus:
<HTML> <HEAD><TITLE> HTML Agility Bug Demo</TITLE></HEAD> <BODY> <table> <tr><td>first row</td></tr> <tr><td>second row</td></tr> <tr><td>third row</td></tr> </table> </BODY> </HTML>
HtmlAgilityPack.HtmlDocument doc = new HtmlDocument(); doc.Load("HtmlAgilityBugDemo.html"); HtmlNodeCollection rowNodes = doc.DocumentNode.SelectNodes("//table/tr"); foreach(HtmlNode row in rowNodes) { string test1 = row.InnerText; string test2 = row.SelectSingleNode("//td").InnerText; // This ALWAYS returns "first row" !!! }
test1 works, it is first "first row" then "second row" then "third row".
test2 is always "first row". The scope of the row object SelectSingleNode() should be isolated to its current location and below only, but it seems that it selects from the root above.