xsl-list
[Top] [All Lists]

RE:

2004-01-08 02:11:14

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



<Prev in Thread] Current Thread [Next in Thread>
  • RE:, Andrew Welch <=