Connecting Tech Pros Worldwide Forums | Help | Site Map

To count the total number of specific element in xml using xsl

Newbie
 
Join Date: Nov 2008
Posts: 5
#1: Nov 17 '08
Hi,

Is there any option to count the total number of specific element using XSL?

XML File:

<root>
<child>Name:
<child1>Text1</child>
<child1>Text2</child>
<child1>Text3</child>
</child>
</root>

I need to count the total number of element <child1> to be calculated and the value to be inserted using the other new element using XSL.

Output:

<root>
<child>Name:
<child1>Text1</child>
<child1>Text2</child>
<child1>Text3</child>
<NEWCHILD2>3</NEWCHILD2>
</child>
</root>

Thanks in Advance,
Radhakrishnan.

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,651
#2: Nov 17 '08

re: To count the total number of specific element in xml using xsl


yup, use the count() function.

regards
Reply