OZONE Asylum
Forums
XML - XSL - XSLT - XHTML - CSS - DOM
XML file to 'nested' list?
This page's ID:
11123
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
I have an xml file that is something like [code] <menu> <menuitem> <name>Products</name> <link>#</link> <menuitem> <name>Printing</name> <link>#</link> </menuitem> <menuitem> <name>Whatever</name> <link>#</link> <menuitem> <name>Whatever-Sub</name> <link>#</link> </menuitem> </menuitem> </menuitem> </menuitem> [/code] How could I break this down into a menu structure like -Products ---Printing ---Whatever ------Whatever-Sub ---Something ------Something1 ---------Something2 ---------Whateverblah What I have so far, is something along the lines of [code] <xsl:for-each select="menu/menuitem"> </xsl:for-each> <script> var oMenu1 = new Menu(); <xsl:for-each select="menu/menuitem"> <xsl:if test="count(menuitem) = 0"> var oMenu1A = oMenu1.CreateLink(); oMenu1A.displayHtml = "<xsl:value-of select="name" />"; oMenu1A.href = "<xsl:value-of select="link" />"; </xsl:if> <xsl:if test="count(menuitem) > 0"> var oMenu1B = oMenu1.CreateMenu(); oMenu1B.displayHtml = "<xsl:value-of select="name" />"; <xsl:for-each select="menuitem"> var oMenu1B_a = oMenu1.CreateLink(); oMenu1B_a.displayHtml = "<xsl:value-of select="name" />"; oMenu1B_a.href = "<xsl:value-of select="link" />"; oMenu1B.AddItem(oMenu1B_a); </xsl:for-each> oMenu1.AddItem(oMenu1B); </xsl:if> <xsl:if test="count(menuitem) = 0"> oMenu1.AddItem(oMenu1A); </xsl:if> </xsl:for-each> [/code] However, for each 'level' of nesting I want to be able to handle, it seems like I need to do another for-each. While my current use for this is only going to have maybe 3 levels tops, its not that bad. My worry is if it needs to get any bigger, I dont want to keep adding level after level of for-each.
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »