XSL forloop help

  • 15 years ago

    this is my sample xml
    <root>
     <artist>
       <name>Jackson</name>
       <songlist>
         <songs>
            <sid>001</sid>
            <sname>Sample 1</sname>
         </songs>
         <songs>
            <sid>002</sid>
            <sname>Sample 2</sname>
         </songs>
       </songlist>
       <genrelist>
          <genre>
             <gid>001</gid>
             <gname>Rock</gname>
          </genre>
          <genre>
             <gid>002</gid>
             <gname>R&B</gname>
          </genre>
       </genrelist>
     </artist>


     <artist> ....... and it goes </artist> ....
    </root>


    now how can i loop throug artist by filtering them according to genre and then list name and all the songs of each artist


    i have something like:
    <xslarse>
    <xsl:stylesheet>
    <xsl: template match:"root">
      <xsl:for-each select="artist">
         <xsl:for-each select="genrelist/genre">
           <xsl:if test="gid='001'">
             <xsl:valueOf select="name">
             <xsl:for-each select="songlist/songs">
             <xsl:valueOf select="sname">
       
    close foreachs and ifs


    but the song names don't display? please help thank!

Post a reply

No one has replied yet! Why not be the first?

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“C++ : Where friends have access to your private members.” - Gavin Russell Baker