Get the value of the current node

I am not too familiar with the terminology, so I'm not even sure that the title of the question is correct, but I will try to explain what I can.

I have an example below XML.

<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 to language nodes (/ countries / country /, and then for each for languages).

<language percentage="11">Turkic</language>

Using XSLT, how can I deduce the value in the above example "Turkic". I can’t think of another way to formulate the question, but it, as I am in node, and I don’t know the syntax to capture the value of this node.

Thanks in advance

+4
source share
1 answer

Element xsl:value-ofu current()should do the trick:

<xsl:value-of select="current()"/>

, , , :

<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>
+8

All Articles