Reputation: 7768
I have html body and I use this code to select particular piece of code and then, wiht the second line, I try to isolate other elements which are part of that particular node.
HtmlNode node = doc.DocumentNode.SelectSingleNode("//table[@class='ts']");
HtmlNodeCollection prices = node.SelectNodes("//span[@class='nobr']");
but, when 'node' does not contain 'nobr span', elements are pulled from entire 'doc'; how can I limit this search to selected node only?
Upvotes: 0
Views: 449
Reputation: 63065
.//
start from the current node and search just its descendants:
HtmlNodeCollection prices = node.SelectNodes(".//span[@class='nobr']");
Upvotes: 2