NEWBIE: Very simple XPATH query

V

Victor

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>
 
P

Philippe Poulard

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>


--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top