Reputation: 5362
I have an XML file with these values:
<query>
<club>First</club>
</query>
And an XSLT file where I want to retrieve the value from the XML. How can I retrieve and store the club value in a variable in XSLT? I've done something similar in XSL by storing variables like this:
<xsl:variable name="testVar">
<xsl:choose>
<xsl:when test="$variable = 'hello'">
<xsl:text>msg=hello</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>msg=bye</xsl:text>
</xsl:otherwise>
</xsl:choose>
But not with XPATH...
Upvotes: 1
Views: 4300
Reputation: 4403
For XPath, just use the select=
attribute to address your item:
<xsl:variable name="givenClub" select="/query/club"/>
... or, if your current node is query
, then:
<xsl:variable name="givenClub" select="club"/>
Upvotes: 3