View Single Post
  #1 (permalink)  
Old March 8th, 2005, 03:46 AM
mdawoodk mdawoodk is offline
Registered User
 
Join Date: Mar 2005
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to get xml tag names in xslt

I want to get xml tag names in xslt file. i tried to use name() in value-of but it is giving me wrong result (mag mag), which is the repeatition of the select in for-each. i need result same as "first,second,first,second". my concern is to get the tag names of child elements of tag supplied in for-each's select. it is really urgent.

xml file:-
<mags>
<mag> <first>1</first><second>2</second></mag>
<mag> <first>99</first><second>88</second></mag>
</mags>

xslt logic:-
<xsl:template match="/">
<xsl:for-each select="/mags/mag">
  <xsl:value-of select="name()"/>
</xsl:for-each>
</xsl:template>

Reply With Quote