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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:34:46+00:00 2026-06-05T16:34:46+00:00

I would like some help parsing a dynamic (folder.subfolders) xml with xslt, I tried

  • 0

I would like some help parsing a dynamic (folder.subfolders) xml with xslt, I tried a few things but I’m not there yet. Here is the structure of the xml that I have:

<FOLDERS>
    <FOLDER>
      <FOLDERID>2edfb864-5693-4e7f-8f98-4ef6e032d8a5</FOLDERID>
      <NAME>bla</NAME>
      <FOLDERSIZE>33Kb</FOLDERSIZE>
      <LASTMODIFIED>2012-06-07 11:11:02</LASTMODIFIED>
      <SUBFOLDERS />
      <FILES>
        <FILE>
          <FILEID>1825</FILEID>
          <NAME>IMG_15052012_142711.png</NAME>
          <SIZE>33Kb</SIZE>
          <EXTENSION>png</EXTENSION>
          <LASTMODIFIED />
        </FILE>
      </FILES>
    </FOLDER>
    <FOLDER>
      <FOLDERID>c9c5e2b2-ee93-49a2-b8be-d86e41528071</FOLDERID>
      <NAME>TestFolder</NAME>
      <FOLDERSIZE>0Kb</FOLDERSIZE>
      <LASTMODIFIED>2012-06-05 00:00:00</LASTMODIFIED>
      <SUBFOLDERS>
        <FOLDER>
          <FOLDERID>3b43fe58-db85-43e6-b541-77ce250afc78</FOLDERID>
          <NAME>SubFolder</NAME>
          <FOLDERSIZE>362Kb</FOLDERSIZE>
          <LASTMODIFIED>2012-06-05 00:00:00</LASTMODIFIED>
          <SUBFOLDERS>
            <FOLDER>
              <FOLDERID>ac1d35d0-80fd-4d97-8101-4de408f24dbd</FOLDERID>
              <NAME>subsub</NAME>
              <FOLDERSIZE>0Kb</FOLDERSIZE>
              <LASTMODIFIED>2012-06-05 00:00:00</LASTMODIFIED>
              <SUBFOLDERS />
              <FILES />
            </FOLDER>
            <FOLDER>
              <FOLDERID>7cfdc199-9d0e-4f86-904d-eda3521f3e87</FOLDERID>
              <NAME>SUBSUB1</NAME>
              <FOLDERSIZE>0Kb</FOLDERSIZE>
              <LASTMODIFIED>2012-06-05 00:00:00</LASTMODIFIED>
              <SUBFOLDERS />
              <FILES />
            </FOLDER>
          </SUBFOLDERS>
          <FILES>
            <FILE>
              <FILEID>1833</FILEID>
              <NAME>Untitled.png</NAME>
              <SIZE>121Kb</SIZE>
              <EXTENSION>png</EXTENSION>
              <LASTMODIFIED />
            </FILE>
            <FILE>
              <FILEID>1834</FILEID>
              <NAME>Untitled.png</NAME>
              <SIZE>121Kb</SIZE>
              <EXTENSION>png</EXTENSION>
              <LASTMODIFIED />
            </FILE>
            <FILE>
              <FILEID>1839</FILEID>
              <NAME>Untitled.png</NAME>
              <SIZE>121Kb</SIZE>
              <EXTENSION>png</EXTENSION>
              <LASTMODIFIED />
            </FILE>
          </FILES>
        </FOLDER>
      </SUBFOLDERS>
      <FILES />
    </FOLDER>
    <FOLDER>
      <FOLDERID>1ead58e2-a412-4318-9629-d5c70d8681bc</FOLDERID>
      <NAME>TestFolder1</NAME>
      <FOLDERSIZE>241Kb</FOLDERSIZE>
      <LASTMODIFIED>2012-06-05 00:00:00</LASTMODIFIED>
      <SUBFOLDERS />
      <FILES>
        <FILE>
          <FILEID>1832</FILEID>
          <NAME>Untitled.png</NAME>
          <SIZE>121Kb</SIZE>
          <EXTENSION>png</EXTENSION>
          <LASTMODIFIED />
        </FILE>
        <FILE>
          <FILEID>1837</FILEID>
          <NAME>Untitled.png</NAME>
          <SIZE>121Kb</SIZE>
          <EXTENSION>png</EXTENSION>
          <LASTMODIFIED />
        </FILE>
      </FILES>
    </FOLDER>
  </FOLDERS>
  <FILES>
    <FILE>
      <FILEID>1836</FILEID>
      <NAME>Untitled.png</NAME>
      <SIZE>121Kb</SIZE>
      <EXTENSION>png</EXTENSION>
      <LASTMODIFIED />
    </FILE>
    <FILE>
      <FILEID>1869</FILEID>
      <NAME>WallPaper.png</NAME>
      <SIZE>7.1Mb</SIZE>
      <EXTENSION>png</EXTENSION>
      <LASTMODIFIED />
    </FILE>
  </FILES>

The thing is that I don’t know how deep the folders/subfolders tree can be.
I did already something but it is still static, it needs to be dynamic also, especially the select part if the xslt condition.

What do you guys think the best approach to parse the xml in this case?

This is the structure I would like to have:

Folders
     Subfolders       
          Subfolders 
               Subfolders
               Files
          Files
     Files 
Files  

And this is what I have now:

<xsl:variable name="folderRoot" select="$xml/ROOT/FOLDERS/FOLDER" />
<xsl:variable name="fileRoot" select="$xml/ROOT/FILES/FILE" />

//Loop through the root folder
<xsl:if test="count($folderRoot) &gt; 0">
  <xsl:call-template name="folder"/>
</xsl:if>

//Loop through the root files    
<xsl:if test="count($fileRoot) &gt; 0">
   <xsl:call-template name="files"/>
</xsl:if>

//files template
 <xsl:template name="files">
    <xsl:for-each select="$fileRoot">
      <tr>
        <td class="defaultIcon {EXTENSION}">
        </td>
        <td>
          <xsl:value-of select="NAME" />
        </td>
      </tr>
    </xsl:for-each>
  </xsl:template>

//Folder template
 <xsl:template name="folder">
    <xsl:for-each select="$folderRoot">
      <tr>
        <td>
          <img src="/default/components/bestandsbeheer/images/folder.png" width="16" height="16" />
        </td>
        <td>
          <xsl:value-of select="NAME"/>
        </td>
        <td> </td>
        <td>Map</td>
        <td>
          <xsl:value-of select="LASTMODIFIED" />
        </td>
      </tr>
      <!--SUBFOLDER 1 -->
      <xsl:if test="count(SUBFOLDERS/FOLDER) &gt; 0">
        <xsl:for-each select="SUBFOLDERS/FOLDER">
         <!--SUBFOLDER 2 -->
          <xsl:if test="count($folderRoot/SUBFOLDERS/FOLDER/SUBFOLDERS/FOLDER) &gt; 0">
            <xsl:for-each select="$folderRoot/SUBFOLDERS/FOLDER/SUBFOLDERS/FOLDER">
            </xsl:for-each>
          </xsl:if>
          <xsl:if test="count($folderRoot/SUBFOLDERS/FOLDER/FILES) &gt; 0">
            <xsl:for-each select="$folderRoot/SUBFOLDERS/FOLDER/FILES">
            </xsl:for-each>
          </xsl:if>
        </xsl:for-each>
      </xsl:if>

      //Files belong to a sub folder
      <xsl:if test="count(FILES) &gt; 0">
        <xsl:for-each select="FILES/FILE">

        </xsl:for-each>
      </xsl:if>

    </xsl:for-each>
  </xsl:template>

Let me know if something is not clear.

  • 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-05T16:34:47+00:00Added an answer on June 5, 2026 at 4:34 pm

    Something like this? It’s a skeleton structure but you get the idea.

    http://www.xmlplayground.com/c848Vl

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

Sidebar

Related Questions

I would like some help parsing a string of someones name. I would like
I would like some help parsing a string of someones name. I would like
I'm new to the site. would like some help if at all possible. I
I would like to as some help. Is there a certain method in javascript/jquery
Good morning! I would like to ask some help from you guys on how
I need some help figuring out how I should do this. I would like
I am working with an array and need some help. I would like to
I am quite new in vbs and I would like some of your help
OK suppose I'm parsing some XML (the problem exists while reading any language but
I would like to show multiple Placemarks by parsing a kml file. Please help,

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.