XPath: Select node based on depth of descendant node type
I need to return the string "A1" or the string "A2" dependent upon the maximum depth of the "B" nodes beneath their containing nodes: <xmlDoc> <A>A1 <B> <B> <B> </B> </B> </B> <B> </B> </A> <A>A2 <B> <B> </B> </B> <B> <B> </B> </B> </A> </xmlDoc> The descendant axis does not seem appropriate to determine the "depth" of the B nodes (Ex: /xmlDoc/A[count(descendant::B)>2]). The "A" node containing the string "A1" has a maximum "B" node depth of 3 but seems to have 4 "descendant" "B" nodes... How would one construct an XPath expression to return the string "A1" based upon the "3 deep" occurrence of the "B" nodes in the first "A" node?
Descendant counts all children of the node. If you want chain of B nodes, write it so /xmlDoc/A[B[B[B]]]
How to add CVS informations in a JSP xml format to view in the source
Problem with SimpleDOM and sortedXPath
How do I include a Map of Strings as attributes in an xml tag using Scala?
Trying to add to a toolbar and menubar in KDevelop 4
Is there a XML Schema validation library that supports the default attribute value?
How would I increment the (version) value of an XML element using AWK?
help with xml transformation
Problems with “select yn in case”
XSD: how to use 'unique' & 'key'/'keyref' with element values?
dbms_xmlgen.getxml - How to set a date format
What is an XML processing instruction, and why is there so little information about them?
XML Package error in 2.12, but not 2.10
Cocoa: Loading a XML File (array);
Which XML serialization library for Scala?
Recursion between different methods of the same multimethod
xsltproc very slow processing HTML piped through tidy