Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get count of childnodes in XML file using XQuery

Tags:

java

xml

xquery

I want to get or return the number of item(<recROw></recROw>) in an xml file using the XQUERY. Is there an easy way to do that in XQuery?

Here is my sample XML data:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<DailyRecord>
  <recROw>
    <id>1</id>
    <name>John Smith</name>
    <gender>male</gender>
    <status>active</status>
  </recROw>
  <recROw>
    <id>2</id>
    <name>James Bond</name>
    <gender>male</gender>
    <status>active</status>
  </recROw>
<DailyRecord>

Any help and ideas would be appreciated. Thank you in advance!

like image 906
napstyr maceda Avatar asked Jun 21 '13 04:06

napstyr maceda


1 Answers

Try

count(/DailyRecord/recROw)
like image 148
Michael Kay Avatar answered Oct 21 '22 11:10

Michael Kay