Greetings
How do you find the deepest node?
So for this example, String would be the deepest node:
and the result that I want is 5
<org.olat.course.nodes.STCourseNode> 0 <ident>81473730700165</ident> 1 <type>st</type> <shortTitle>General Information</shortTitle> <moduleConfiguration> 2 <config> 3 <entry> 4 <string>allowRelativeLinks</string> 5 <--- <string>false</string> </entry> <entry> <string>file</string> <string>/kgalgemeneinformatie.html</string> </entry> <entry> <string>configversion</string> <int>3</int> </entry> <entry> <string>display</string> <string>file</string> </entry> </config> </moduleConfiguration> </org.olat.course.nodes.STCourseNode>
Note: I use php, xpath
Other possibilities are also welcome 🙂
Kind regards
Dieter Verbeemen
With XPath 2.0 you could write a single XPath expression I think, as
max(descendant::*[not(*)]/count(ancestor::*)). With XPath 1.0 you could find the node with XSLT as the host language as inIf you use PHP as the “host” language for XPath you can probably write something similar with a loop over
descendant::*[not(*)], the elements not having any child elements, and computingcount(ancestor::*)for each of them and storing the maximum value.[edit] Here is some attempt at PHP: