Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Counting nodes 1

Status
Not open for further replies.

mcowen

Programmer
Oct 21, 2001
134
GB
I want to count the number of cases in my xsl page (CASE being the parent element). I see that there is a XPath function called count() but I dont know how to use it nor whether it does what I want.

Thanks
Matt
Visualfiles Ltd
 
You call count() with an XPath query and it returns the number of hits. It's fairly slow, so don't overuse it.
Code:
<xsl:if test=&quot;count(/rootnode/a/b/c) > 0&quot;>
   <!-- do something -->
</xsl:if>
Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Cheers for this. This looks correct but XMLSpy says this is not well formed and it expects an & before the less than symbol.

<xsl:if test=&quot;count(VFILE_DATA/SUMMARY) < 2&quot;/>;

</xsl:if>
 
Ok sorted it. When using this in a XSL page you need to convert the < char to &quot;&lt;&quot;.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top