views:

1068

answers:

1

Is it possible to get the total number of XML nodes?

Also, how does one do a for-statement with XSLT?

+4  A: 

If you want to count the node of you XML you could use count(object/node) and it will be something like this:

 <xsl:value-of select="count(/root/*)"/>

The instruction above will let you know how many child nodes does your root node has

<xsl:for-each select="/root/element-you-wanna-loop" >
    <!-- Do something with your nodes here -->    
</xsl:for-each>

Hope this helps you.

chermosillo
How would I get the current node number?
you should replace the /root for you current node if you're in that node you could just use the count(*)
chermosillo