Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 7th, 2008, 11:23 AM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default 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

 
Old November 7th, 2008, 11:27 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

The count() function is probably what you want.

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


/- Sam Judson : Wrox Technical Editor -/
 
Old November 7th, 2008, 11:59 AM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

Perfect that works
Thank you guys






Similar Threads
Thread Thread Starter Forum Replies Last Post
not able to print out the child nodes eruditionist XSLT 7 October 30th, 2008 10:33 AM
text and child nodes eepyoga XSLT 1 April 8th, 2008 12:45 PM
Retrieveal of child nodes.... nathilson21 Classic ASP XML 0 May 7th, 2007 04:54 AM
Trying to group child nodes aalbetski XSLT 3 November 18th, 2006 01:29 PM
counting child nodes Tomi XSLT 1 September 6th, 2006 03:26 AM





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