Reputation: 411
I want to count no of elements under a node , In below XML I has 2 report entries , In first entry I has 4 elements and in 2nd entry I has only 3 address is missing.
I want to count the total elements under each report_entry count is 4 for first report entry and count is 3 for 2nd report entry
Can some body suggest is it possible ? any sample code ?
example xml:
<?xml version="1.0" encoding="UTF-8"?>
<report_data>
<report_entry>
<id>12345</id>
<fname>Venkata</fname>
<lname>Penumatsa</lname>
<address>Hyderabad</address>
</report_entry>
<report_entry>
<id>123453</id>
<fname>stephen</fname>
<lname>florida</lname>
</report_entry>
</report_data>
-- Venkata
Upvotes: 1
Views: 1555
Reputation: 167781
Use
<xsl:template match="report_entry">
<xsl:value-of select="count(*)"/>
</xsl:template>
if you "want to count the total elements under each report_entry".
Upvotes: 2