[xsl] RE:

Subject: [xsl] RE:
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Thu, 8 Jan 2004 09:11:14 -0000
> Dear friends,
> 
> I want to count the number of elements and nodes in a xml 
> with an xsl. can u say a way6 to do it.
> 
> <A>
>      <A1>
>                     <A12>
>           <A12>
>           <A12>
>      </A1>
>                 <A2>
>           <A12>
>           <A12>
>      </A2>
> ....
> </A>
> 
> i should get a sum in this case of  8 ie sum of nodes and 
> childs .. how to get this done .


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

...will count all of the elements (not text or whitespace nodes)

Ps. your xml isn't well formed.  If there should be 8 elements, then
<A12> should be <A12/>.

cheers
andrew

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread