How to save an XML attribute (with an XML value passing some test) in an XSL variable?
Having the following xml:
<countries>
<country id="1">Andora</country>
<country id="2">Bulgaria</country>
<country id="3">Croatia</country>
<country id="4">Danemark</country>
<country id="5">Estonia</country>
</countries>
How can I save the Andora attribute "@id" in the xsl variable :? Sort of
<xsl:variable name="andora_id" select=???????>
so that I can use "$ andora_id" with a value of "1" later in the rest of my xsl?
How can I save the @id attribute? Andora in xsl variable: variable? Something like
<xsl:variable name="andora_id" select=???????>so that I can use "$ andora_id" with a value of "1" later in the rest of my xsl?
This is an XPath question.
Using
<xsl:variable name="andora_id" select="/*/country[.='Andora']/@id"/>
xsl:variable andora_id, node -set id country, XML 'Andora'.