Connecting Tech Pros Worldwide Help | Site Map

XPATH query (count)

Newbie
 
Join Date: Aug 2007
Posts: 23
#1: Aug 6 '08
Expand|Select|Wrap|Line Numbers
  1. <root>
  2.   <row>
  3.     <col name="Surname">McEnroe</col>
  4.     <col name="Postcode">44312</col>
  5.     <col name="PolicyID">X1234565V</col>
  6.   </row>
  7. <root>
  8.   <row>
  9.     <col name="Surname">McEnroe</col>
  10.     <col name="Postcode">44312</col>
  11.     <col name="PolicyID">X1234565V</col>
  12.   </row>
  13.   <row>
  14.     <col name="Surname">Green</col>
  15.     <col name="Postcode">44123</col>
  16.     <col name="PolicyID">A65432123M</col>
  17.   </row>
  18.  <row>
  19.     <col name="Surname">Green</col>
  20.     <col name="Postcode">SW932P</col>
  21.     <col name="PolicyID">A6543212333M</col>
  22.   </row> 
  23.   </root>
  24.  
Hi I need to write a xpath query that return the number of results (count) with a given surname and postocode .eg for Green and 44123 will return 1 but for McEnroe and 44312 will return 2 ....

I tried and tried but I cant get it to work any ideas??
Moderator
 
Join Date: Mar 2006
Posts: 1,103
#2: Aug 6 '08

re: XPATH query (count)


Expand|Select|Wrap|Line Numbers
  1. count(/root/row[col[@name='Surname']='Green'][col[@name='PostCode']='44123'])
Reply