Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Problem selecting within a node

$
0
0

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.


Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>