Jump to content

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

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 post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...