xml - How can I select only specific subelements in XQuery? -


say have elements <country>, , elements have lots of subelements <name>, <population>, <cities>, of have own subelements. if call

for $x in doc("myfile.xml")/world return <country> { $c/country } </country> 

then i'll of countries, of subelements, subelements, , on. however, want select of cities in country, including subelements of cities. how can this?

you use xpath expressions select elements in xquery.

  • $x/country/* selects child elements of country.
  • $x/country/cities selects <cities/> child elements
  • $x/country/(name|population|cities) selects specified child elements (| union operator, , parenthesis create sequence)

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -