SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Aug 2005
    Posts
    254
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XSL to output nested lists

    Hi I have an XML file called structure which shows the hierarchical structure of my website using outline elements.

    I want to output a nested list of all pages for a sitemap. I tried this type of approach to output a list item then the next level of ul (if it has a child).

    Code:
    <xsl:template match="/opml/body/outline/outline">
      <li>
      <a>       
        <xsl:attribute name="href">
        <xsl:value-of select="@rel_url"/></xsl:attribute>
         <xsl:value-of select="@text" />
      </a>  
      <!-- if there is a child element -->
      <xsl:if test="*">     
         <ul>  
           <xsl:apply-templates select="/opml/body/outline/outline/outline" />    
         </ul>
      </xsl:if> 
      </li>
    </xsl:template>
    However the problem is that when 2 list items on the level have children ALL the children are shown for each li with children. I only want the children for each list item to be shown.

    Any ideas?

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    without the source xml file, there is very little that we can do to help you.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •