first child node name in xslt

Viewed 13607

I wanted to know how to find the first child node name of a specific node in xslt.

I have an xml:

 <name>
    <body>
      <para>
        <text> some text</text>
      </para>
    </body>
  </name>

Can i get a name using body/node()[1]/local-name()?

<xsl:template match="name">
<name> 
<xsl:variable name="firstchild" select="body/node()[1]/local-name()">
                        </xsl:variable>
 <xsl:value-of select="$firstchild" />
 </name>
</xsl:template>

The output should be

 <name>
    para
  </name> 
1 Answers
Related