|
-
December 22nd, 2004, 06:23 PM
#1
[Very simple newbiequestion] Selecting childnodes with foreach and apply templates.
I have an XML which looks like this:
<dvdcollection>
<dvd id="1">
<title>Text</title>
<releasedate>Text</releasedate>
<runningtime>Text</runningtime>
<rating>Text</rating>
<actors>
<actor>Text</actor>
<actor>Text</actor>
<actor>Text</actor>
</actors>
</dvd>
</dvdcollection>
I'm presenting the data in a simple html-table with XSLT and want to print all the actors in one <td> with <br /> after each i use this XSLT:
<xsl:template match="actors">
<xsl:for-each select=".">
<xsl:value-of select="actor"/><br />
</xsl:for-each>
</xsl:template>
and in a for-each loop I use <td><xsl:apply-templates select="actors"/></td> as the tutorial on apply-templates on w3schools shows. I can display the title and other elements by just using <xsl:value-of select="title"/> but with this code I only get the first <actor> element in the tree. 
What am I missing?
Ive tried having two foreach loops inside eachother but that didn't work and I've heard apply-templates is better in many ways. Please help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|