Jump to content

How do I select a specific occurance of an xml tag?


groads2

Recommended Posts

Use a positional predicate foo[x] (the first index is 1) e.g.

<xsl:template match="/">  <xsl:value-of select="root/foo[3]"/></xsl:template>

outputs the string value of the third 'foo' child element of the 'root' element.If you are not looking for a certain child element but for the third 'foo' element in the complete document (where 'foo' elements could exist at different nesting levels) then use

<xsl:template match="/">  <xsl:value-of select="(//foo)[3]"/></xsl:template>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...