0

I have a xml drafted as follows

<node1>
  <node2>
    <node3>
      val3
    </node3>
    <node4>
      val4
    </node4>
  </node2>
</node1>

i m using XSLT to get values from node3 and node 4 So far so good and I m getting the values. as

val3
val4

I m using the xslt loop as follows

<xsl:for-each select="/node1/node2">

</xsl:for-each>

Now I need to get the names of nodes also. i.e. i need the following output

node3: val3
node4: val4
Gautam
  • 1,728
  • 8
  • 32
  • 67

1 Answers1

1

for instance :

  <xsl:template match="/">
    <xsl:for-each select="node1/node2/*">
      <xsl:value-of select="name()"/> : <xsl:value-of select="text()"/>
    </xsl:for-each>  
  </xsl:template>

I get :

node3 : 
      val3
    node4 : 
      val4
Istao
  • 7,425
  • 6
  • 32
  • 39
  • I tried this but I m getting something like Node2: val3 node2: val4...I did not use tag though.. – Gautam May 22 '13 at 10:06