NEWBIE: XPATH question

V

Victor

Hallo again, just another really simple query that has taken me all
morning to attempt to not get going.

This is my invalid xpath expression which is what I have tried to
write but fail.

COMPANY/EMPLOYEE/EMPLOYEEDETAILS/count()

What I want is to count the number of <EMPLOYEEDETAILS> for each
<EMPLOYEE> so that my xpath for employee number 1000 calculates 1,
employee number 1001 calculates 1, and employeenumber 1002 calculates
2 (because there are two <EMPLOYEEDETAILS> for the same employee
number).

All help thank you and for everyone that thought about my problem this
morning too. Here is the sample XML.
Victor

<COMPANY>

<EMPLOYEE>
<EMPLOYEENUMBER uknational="true">
1000
</EMPLOYEENUMBER>
<EMPLOYEEDETAILS>
<EMPLOYEENAME>Mary</EMPLOYEENAME>
<NATIONALINSURANCENUMBER>1234567890<NATIONALINSURANCENUMBER>
</EMPLOYEEDETAILS>
</EMPLOYEE>

<EMPLOYEE>
<EMPLOYEENUMBER uknational="false">
1001
</EMPLOYEENUMBER>
<EMPLOYEEDETAILS>
<EMPLOYEENAME>Victor</EMPLOYEENAME>
<EMPLOYEENATIONALINSURANCENUMBER/>
</EMPLOYEEDETAILS>
</EMPLOYEE>

<EMPLOYEE>
<EMPLOYEENUMBER uknational="true">
1002
</EMPLOYEENUMBER>
<EMPLOYEEDETAILS>
<EMPLOYEENAME>Mary</EMPLOYEENAME>
<NATIONALINSURANCENUMBER>1234567890<NATIONALINSURANCENUMBER>
</EMPLOYEEDETAILS>
<EMPLOYEEDETAILS>
<EMPLOYEENAME>Joanna</EMPLOYEENAME>
<NATIONALINSURANCENUMBER>4323423423424<NATIONALINSURANCENUMBER>
</EMPLOYEEDETAILS>
</EMPLOYEE>

</COMPANY>
 
M

Martin Honnen

Victor wrote:

This is my invalid xpath expression which is what I have tried to
write but fail.

COMPANY/EMPLOYEE/EMPLOYEEDETAILS/count()

count is a function to be applied to a nodeset e.g.
count(//employyeedetails)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top