Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7715939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:30:46+00:00 2026-06-01T02:30:46+00:00

Greetings How do you find the deepest node? So for this example, String would

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:30:47+00:00Added an answer on June 1, 2026 at 2:30 am

    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 in

    <xsl:template match="/">
      <xsl:for-each select="descendant::*[not(*)]">
        <xsl:sort select="count(ancestor::*)" data-type="number" order="descending"/>
        <xsl:if test="position() = 1">
          <xsl:value-of select="count(ancestor::*)"/>
        </xsl:if>
      </xsl:for-each>
    </xsl:template>
    

    If 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 computing count(ancestor::*) for each of them and storing the maximum value.

    [edit] Here is some attempt at PHP:

    $xpath = new DOMXPath($doc);
    
    $leafElements = $xpath->query("descendant::*[not(*)]");
    $max = 0;
    
    foreach ($leafElements as $el) {
      $count = $xpath->evaluate("count(ancestor::*)", $el);
      if ($count > $max) {
        $max = $count;
      }
    }
    // now use $max here
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, Apologies in advance that I have not researched this toughly enough to answer
Greetings! I have an issue here that i can't find. I am getting a
Greetings everyone! I want to know if its possible to find out if a
Greetings, I feel kinda stupid for asking this, but I want to set the
Greetings, I'm trying to find a way to 'unbind' a socket from a particular
Greetings, I'm trying to find either a free .NET library or a command-line executable
Greetings, I'm able to find the size in bytes of a field after padding
Greetings all, I'm trying to localize a .NET/C# project. I'm using string resource files
I've spent far too much time with this and can't find the mistake. Maybe
Greetings! I am trying to find a way in Java to programmatically enable/disable a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.