I am trying to use the value of a parameter or variable as the name of the node inside the select value, but so far has failed.
So my XML is as follows.
<Data> <Name>John Smith</Name> <Date>28112012</Date> <Phone>iphone</Phone> <Car>BMW</Car> </Data>
And my incomplete xslt looks below.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0" exclude-result-prefixes="#all"> <xsl:param name="nodename" select="'Name'"/> <xsl:template match="/Data"> <Output> <xsl:value-of select="{$nodename}"/> </Output> </xsl:template> </xsl:stylesheet>
Ideally, I want out
<Output>John Smith</Output>
Is there any way to do this using XSLT? I want to be able to select a suitable node based on user selection.
thanks
SC
source share