This project has moved. For the latest updates, please go here.


SelectNodes from ChildNodes


It would be nice if I could use SelectNodes() from a child node and have it only select those type of nodes from the child nodes rather then from the entire tree.
A good example, would be that I need to find all links from a specific table. I search for the Table I want, Now all the links I want are child nodes of the table node.
Right now, if I do TableNode.SelectNodes("//a"), it gets ALL links in the document.
I have coded a work around, but it would be a very useful feature that would save a lot of extra code down the road.
Closed Oct 3, 2009 at 2:53 PM by DarthObiwan
There is now an alternative, use Descendants(string name) on the node itself. This will return an IEnumerable<HtmlNode> that is yeilded to be inline with Linq to Objects.


Zagnar wrote Jul 14, 2008 at 6:57 PM

This issue is not valid., you are using the wrong XPath query. Instead of "//a", you should be using ".//a" or just "a" to tell XPath to start at the current node.

wrote Sep 17, 2008 at 1:27 PM

wrote Feb 14, 2009 at 9:50 PM

Edoardo76 wrote Feb 14, 2009 at 9:54 PM

I also have fallen on this mistake.
Using the dot (example .//a) the problem is resolved.
But i think that if it is a common misunderstanding it has somewhat reason.
Doesn't it?


wrote Oct 3, 2009 at 2:53 PM

wrote Feb 22, 2013 at 1:47 AM

wrote May 16, 2013 at 12:33 PM