NEWBIE: Very simple XPATH query

Victor (6)

Usenet Archive
Joined
Feb 3, 2004
Messages
8
Reaction score
0
Hallo, I am hitting my head against a brick wall and can't formulate a simple XPATH query. If someone could help I would be most appreciative.

This xpath "COMPANY/EMPLOYEE/EMPLOYEENUMBER/text" returns 1000 and 1001

This xpath "COMPANY/EMPLOYEE/EMPLOYEEDETAILS/EMPLOYEENAME/text" returns Mary and Victor

This xpath "COMPANY/EMPLOYEE/EMPLOYEENUMBER[@uknational="true"]/text" returns 1000

I can't work out the syntax to combine them and return only the employee names (not employee numbers) where uknational="true", ie a xpath query that returns COMPANY/EMPLOYEE/EMPLOYEEDETAILS/EMPLOYEENAME/text where uknational="true"

All help appreciated and thank you in advance.
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>

</COMPANY>
 

Philippe Poulard

Usenet Archive
Joined
Dec 20, 2001
Messages
412
Reaction score
0
Victor said:
Hallo, I am hitting my head against a brick wall and can't formulate a simple XPATH query. If someone could help I would be most appreciative.

This xpath "COMPANY/EMPLOYEE/EMPLOYEENUMBER/text" returns 1000 and 1001

This xpath "COMPANY/EMPLOYEE/EMPLOYEEDETAILS/EMPLOYEENAME/text" returns Mary and Victor

This xpath "COMPANY/EMPLOYEE/EMPLOYEENUMBER[@uknational="true"]/text" returns 1000

I can't work out the syntax to combine them and return only the employee names (not employee numbers) where uknational="true", ie a xpath query that returns COMPANY/EMPLOYEE/EMPLOYEEDETAILS/EMPLOYEENAME/text where uknational="true"

All help appreciated and thank you in advance.

try this :
COMPANY/EMPLOYEE[EMPLOYEENUMBER/@uknational="true"]/EMPLOYEEDETAILS/EMPLOYEENAME/text
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>

</COMPANY>
 

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
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top