Getting xml node’s name

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • li72
    New Member
    • Aug 2007
    • 13

    Getting xml node’s name

    Hi. Guys
    I have an xml doc like the one below. I wonder how to read the name of each node in the xml doc. i.e. p1, p2 and p3 then store them into variables. Is it possible to do this using XSLT. How?

    Your help is much appreciated

    Cheers

    <login>

    <p1 id="x" password="y" />


    <p2 id="xx" password="yy" />


    <p3 id="xxx" password="yyy" />


    </login>
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    The name can be given by the xpath "local-name()" at each node.

    What do you mean by store into variables?
    Code:
    <xsl:template match="*">
      <xsl:variable name="name" select="local-name()"/>

    Comment

    Working...