xsl how to count the nodes in a xml file
I have a xml sample file generated from the schema.
<ns0:PurchaseOrder xmlns:ns0=”http://yourprojectname.Schemas.PO”>
<PONumber>PONumber_0</PONumber>
<PODate>1999-05-31</PODate>
<POQty>POQty_0</POQty>
<Customer>
<Name1>Google</Name1>
<Name1>Google web</Name1>
</Customer>
</ns0:PurchaseOrder>
now, in order to find a countthe nodes in a xml file , you need to place the below code in the buffer are of the inline XSLT call template
<xsl:template name=”MyXsltSampleTemplate”>
<xsl:variable name=”countofPO” select=”count(/*[local-name()='PurchaseOrder' and namespace-uri()='http://yourprojectname.PO']/*[local-name()='Customer' and namespace-uri()='']/*[local-name()='Name1' and namespace-uri()=''])”/>
<xsl:element name=”countofPO”>
<xsl:value-of select=”$countofPO”/>
</xsl:element>
</xsl:template>
Thanks
Posted: August 4th, 2008 under BizTalk, xml, xsl, xslt.
Tags: count the nodes in xml file