...

View Full Version : I don't understand the interaction of xsl:for-each and xsl:value-of



brothercake
12-15-2002, 05:20 AM
Say I've got really simple xml:



<webpage>
<para>some text in paragraph 1</para>
<para>some text in paragraph 2</para>
<para>some text in paragraph 3</para>
</webpage>


And what I want to do is:



<xsl:for-each select="webpage/para">
<p>
<xsl:value-of select="para" />
</p>
</xsl:for-each>


But of course it doesn't work - there's no <para> inside <para> to get the value of !

I'm obviously failing to grasp something fundamental ... ??

jkd
12-15-2002, 04:30 PM
Inside the for-each, the para element is now the context node.

Use:

<xsl:value-of select="."/>

:)

brothercake
12-15-2002, 04:53 PM
Simple as that ... That clears it up nicely. Thanks :thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum