p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   How to get the size of the child nodes. (http://p2p.wrox.com/showthread.php?t=71355)

eruditionist November 7th, 2008 11:23 AM

How to get the size of the child nodes.
 
<?xml version="1.0"?>
<ss>
    <id>
        <picture>image.jpg</picture>
        <text>sample text </text>
    </id>
    <id>
        <picture>image.jpg</picture>
        <text>sample text </text>
    </id>
    <id>
        <picture>image.jpg</picture>
        <text>sample text </text>
    </id>
    <id>
        <picture>image.jpg</picture>
        <text>sample text </text>
    </id>
    <id>
        <picture>image.jpg</picture>
        <text>sample text </text>
    </id>
    <id>
        <picture>image.jpg</picture>
        <text>sample text </text>
    </id>
</ss>

How do I get the total number of ids that are in this xml? for example according to this xml I want to get size = 6


samjudson November 7th, 2008 11:27 AM

The count() function is probably what you want.

Code:

<xsl:value-of select="count(/ss/id)"/>


/- Sam Judson : Wrox Technical Editor -/

eruditionist November 7th, 2008 11:59 AM

Perfect that works
Thank you guys



All times are GMT -4. The time now is 12:21 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.