Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > NEWBIE: XPATH question

Reply
Thread Tools

NEWBIE: XPATH question

 
 
Victor
Guest
Posts: n/a
 
      02-18-2004
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<NATIONALINSURA NCENUMBER>
</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<NATIONALINSURA NCENUMBER>
</EMPLOYEEDETAILS>
<EMPLOYEEDETAILS>
<EMPLOYEENAME>Joanna</EMPLOYEENAME>
<NATIONALINSURANCENUMBER>4323423423424<NATIONALINS URANCENUMBER>
</EMPLOYEEDETAILS>
</EMPLOYEE>

</COMPANY>
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      02-18-2004


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

Martin Honnen
http://JavaScript.FAQTs.com/

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Memory leak" in javax.xml.xpath.XPath Marvin_123456 Java 4 07-29-2005 03:49 PM
XPath: efficiency in xpath expressions Tjerk Wolterink XML 1 11-13-2004 06:03 PM
Are there any XPath parsers that generate XPath trees? goog XML 0 01-14-2004 01:47 PM
XPath that does not include other XPath Anna XML 0 07-31-2003 07:55 AM
Problem selecting a node with XPATH if attribute value contains backslashes - how to force XPATH string to be treated as literal? Alastair Cameron XML 1 07-08-2003 07:24 PM



Advertisments