How can I get the element value only without the sub-node value?
For example
XML
<root>
<a>
parent value
<b>
child value
</b>
</a>
</root>
XSL
<xsl:for-each select="a">
<xsl:call-template name="foo">
<xsl:with-param name="elem" select="." />
</xsl:call-template>
</xsl:for-each>
<xsl:template name="foo">
<xsl:param name="elem" />
<i>Val: <xsl:value-of select="$elem"/></i>
</xsl:template>
The output is: "parent valuechild value" And I want just to display "parent value"
Any suggestions?
Thanks!
Use either:
<xsl:value-of select="$elem/text()"/>
or:
<xsl:value-of select="$elem/text()[1]"/>
depending on whether you want to get the value of all text nodes that are children of a
or only the first one of them.