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 8157111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:10:06+00:00 2026-06-06T17:10:06+00:00

Ive got a long list of xml elements. Each element got an ID and

  • 0

Ive got a long list of xml elements.

Each element got an ID and a PARENT_ID.

How can I make a sitemap/nested list based on this? The elements with null value is the top parent elements.

I want to show the list with UL and LI`s in HTML.

<ROOT>
<SITEMAP>
    <ARRAY>
        <ID>1</ID>
        <NAME>Test</NAME>
        <PARENT_ID>NULL</PARENT_ID>
    </ARRAY>
    <ARRAY>
        <ID>2</ID>
        <NAME>Test2</NAME>
        <PARENT_ID>3</PARENT_ID>
    </ARRAY>
    <ARRAY>
        <ID>3</ID>
        <NAME>Test3</NAME>
        <PARENT_ID>NULL</PARENT_ID>
    </ARRAY>
    <ARRAY>
        <ID>4</ID>
        <NAME>Test4</NAME>
        <PARENT_ID>1</PARENT_ID>
    </ARRAY>
    <ARRAY>
        <ID>5</ID>
        <NAME>Test5</NAME>
        <PARENT_ID>4</PARENT_ID>
    </ARRAY>
</SITEMAP>

  • 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-06T17:10:08+00:00Added an answer on June 6, 2026 at 5:10 pm

    The key template will look something like this:

    <xsl:template matches="ARRAY"> 
       <xsl:variable name="id" select="ID"/>
       <output>
          <!-- output goes here -->
          ...
          <!-- now process every ARRAY with a PARENT_ID equal to the current node's id. (I.e. its children.) -->
          <xsl:apply-templates select="/ROOT/SITEMAP/ARRAY[PARENT_ID = $id]"/>
       </output>
    </xsl:template>
    

    And you kick it off with:

    <xsl:template matches="/">
       <xsl:apply-templates select="/ROOT/SITEMAP/ARRAY[PARENT_ID = 'NULL']"/>
    </xsl:template>
    

    Be aware though that if there are any cycles in your hierarchy, this transformation will run infinitely.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a long list containing different numbers of elements which also can recur
I've got an XBEL formatted XML-file. The out-put is a nested list. I wish
Ive got a view helper in library/my/view/helper/gravatar and so in any view I can
ive got an object that looks like this with print_r(): SimpleDOM Object ( [0]
Ive got this problem: Line 20 (LOOT_FromContainer(container) I need that to use as Invoke
Playing with Erlang, I've got a process-looping function like: process_loop(...A long list of parameters
I've got a long list of codes and text in the same cell. I
I've got my current location lat long and I've got a list of places
I've got a fairly long list of divs which I'm trying to use as
I've got a long-running script, and the operations that it performs can be broken

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.