Jump to content
groads2

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

Recommended Posts

I have an xml that will have 10 instances of a tag. I want to put each instance in a certain place on my html form. How do I select the specific occurance of an xml tag?

Share this post


Link to post
Share on other sites

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>

Share this post


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.

Guest
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.

Loading...

×
×
  • Create New...