I'm trying to find a way to get the total number of child nodes from an XmlNode recursively.
That it is to say I want to count all the children, grand children etc.
I think its something like
node.SelectNodes(<fill in here>).Count
but I don't know what the XPath is.
XPath supports something called Axis specifier, so the code you're looking for is
node.SelectNodes("descendant::*").Count
The XPath you are after is:
descendant::node()
(1)
or
descendant::*
(2)
The first XPath expresion (1) above selects any node (text-node, processing-instruction, comment, element) in the subtree rooted by the current node.
(2) selects any element node in the subtree rooted by the current node.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With