sum selective child nodes

# Thread: sum selective child nodes

1. Junior Member
Join Date
Dec 1969
Posts
4

## sum selective child nodes

Hi all I have the following XML file<BR>&#060;ENVELOPE&#062;<BR> &#060;AMOUNTS&#062;<BR> &#060;AMOUNT&#062;1&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;2&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;3&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;4&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;5&#060;/AMOUNT&#062;<BR> &#060;/AMOUNTS&#062;<BR> &#060;AMOUNTS&#062;<BR> &#060;AMOUNT&#062;6&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;7&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;8&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;9&#060;/AMOUNT&#062;<BR> &#060;AMOUNT&#062;10&#060;/AMOUNT&#062;<BR> &#060;/AMOUNTS&#062;<BR>&#060;/ENVELOPE&#062;<BR><BR>I want to add up the first 3 child nodes in each &#060;AMOUNTS&#062; node to get the total 27.(1+2+3+6+7+8) <BR>Can anybody help me.<BR><BR>Thanx in advance!!<BR>Kevin<BR><BR><BR>

2. God
Senior Member
Join Date
Dec 1969
Posts
18,177

## RE: sum selective child nodes

Does this work?<BR><BR>&#060;xsl:value-of select="sum(/ENVELOPE/AMOUNTS/AMOUNT[position() &lt= 3]" /&#062;

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•