I am trying to use XPath count function to determine how many elements are returned by following query
doc("courses.xml")
count(//Course[contains(Description,"Cross-listed")])
The following code returns 2 course elements
doc("courses.xml")
//Course[contains(Description,"Cross-listed")]
but when I try to use the count function as above to return “2” I get the following error.
Error on line 2 column 1 of tmpDfWgJ7.xq:
XPST0003 XQuery syntax error in #doc(“courses.xml”)
count(//#:
Unexpected token “(” beyond end of query
Static error(s) in query
How can I correct this?
count(doc(“courses.xml”) //Course[contains(Description,”Cross-listed”)])