W Charlton wrote:
Does anyone know an elegant solution to counting all elements in an XML
fragment where the elements to be counted are nested in a tree? An example
of the XML is below:
<xmltree>
<countmein>Node1</countmein>
<nodes>
<node>
<countmein>Node2</countmein>
<level>1</level>
<nodes>
<node>
<countmein>Node3</countmein>
<level>2</level>
<nodes>
<node>
<countmein>Node4</countmein>
<level>3</level>
<nodes/>
</node>
</nodes>
</node>
<node>
<countmein>Node5</countmein>
<level>2</level>
<nodes/>
</node>
<node>
<countmein>Node6</countmein>
<level>2</level>
<nodes/>
</node>
</nodes>
</node>
<node>
<countmein>Node7</countmein>
<level>1</level>
<nodes>
<node>
<countmein>Node8</countmein>
<level>2</level>
<nodes/>
</node>
</nodes>
</node>
</nodes>
</xmltree>
The count in this case would be 8.
count(/descendant::countmein)
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--