I'm not overly familiar with the terminology, so I'm not even sure the title of the question is accurate but I shall try to explain best I can.
I have the below XML example.
<countries>
<country name="Afghanistan" population="22664136" area="647500">
<language percentage="11">Turkic</language>
<language percentage="35">Pashtu</language>
<language percentage="50">Afghan Persian</language>
</country>
</countries>
I use XPath down to the language nodes (/countries/country/ and then a for-each for the languages).
<language percentage="11">Turkic</language>
Using XSLT how can I output the value of , in the above example "Turkic". I can't think of another way to phrase the question but its like I am at the node and don't know the syntax to grab the value of this node.
Thanks in advance
The xsl:value-of
element and current()
function should do the trick:
<xsl:value-of select="current()"/>
I don't know the exact structure of your template, but for instance the following one outputs the language names:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/countries">
<xsl:for-each select="country">
<xsl:value-of select="current()"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With