View Single Post
  #1 (permalink)  
Old August 12th, 2004, 01:53 AM
nimesh nimesh is offline
Registered User
 
Join Date: Aug 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to count total number of nodes in an xml file?

Hi.

Just wondering if anyone can help me.

I need to to write a simple XSLT script which returns the total number of nodes within a sample XML file.
I tried running the following code, but it returns 30 nodes, instead of 20 for the following sample file.
Any ideas how to amend the code so it returns the correct node count?

Thanks!


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
        <xsl:value-of select="count(//node())"/>
    </xsl:template>
</xsl:stylesheet>


<?xml version="1.0" encoding="UTF-8"?>

<FiML version="0-7">
<fiHeader>
<fiSystemTradeIdentifier>
<fiSystemId>Test</fiSystemId>
<fiTrade>
<fiTradeId>12345678</fiTradeId>
<fiVersionNumber>1</fiVersionNumber>
<fiVersionTimestamp>2004-08-04</fiVersionTimestamp>
</fiTrade>
<fiTradeLinkId>10360614</fiTradeLinkId>
</fiSystemTradeIdentifier>
<fiSourcePartyReference href="SOURCE"/>
</fiHeader>
</FiML>



Reply With Quote