...

View Full Version : XSL For Each Child Node



Jazzo
11-01-2008, 08:50 PM
This is my code:


<xsl:for-each select="child::*">
<td>
<xsl:value-of select="/"/>
</td>
</xsl:for-each>


I want it to display the value of each child element in a separate tablecell. Instead it combines every child element into one cell. How would you do this?

jkd
11-01-2008, 09:48 PM
Why "child::*" instead of "./*"?

Jazzo
11-01-2008, 09:53 PM
I don't know but either way it's not working :(

oesxyl
11-01-2008, 10:05 PM
This is my code:


<xsl:for-each select="child::*">
<td>
<xsl:value-of select="/"/>
</td>
</xsl:for-each>


I want it to display the value of each child element in a separate tablecell. Instead it combines every child element into one cell. How would you do this?



<xsl:for-each select="child::*">
<td>
<xsl:value-of select="/"/>
</td>
</xsl:for-each>

try to use '.' or '*' instead of '/' for select in value-of. Which one to use depend of what is child::*.
you can debug the xpath using value-of or message.


<!-- if this don't output something xpath is wrong -->
<xsl:value-of select="child::*">
<xsl:for-each select="child::*">
<td>
<xsl:value-of select="."/>
</td>
</xsl:for-each>


look inside the source page to be sure that show something
best regards

Jazzo
11-01-2008, 10:08 PM
Thank you so much :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum