Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 7th, 2008, 11:23 AM
Authorized User
 
Join Date: Sep 2008
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old November 7th, 2008, 11:27 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
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 -/
Reply With Quote
  #3 (permalink)  
Old November 7th, 2008, 11:59 AM
Authorized User
 
Join Date: Sep 2008
Location: , , .
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

Perfect that works
Thank you guys

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 07:33 PM.


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