xml - Difference between [border @ country] and [border /@ country] -
i have xml file , 1 line of file this
<mondial> <country> <encompassed continent="europe" percentage="100"/> </country> </mondial>
let want select country encompasses continent europe wrote:
<result> { doc("mondial.xml")//country[encompassed @continent="europe"]// city } </result>
but answer says
<result> { doc("mondial.xml")//country[encompassed/ @continent="europe"]// city } </result>
i thought if use "/" right here go next directory in file me please? explanation appreciated
your first example have [encompassed @continent="europe"]
invalid xpath.
your second example valid, although suggest removing space in [encompassed/ @continent="europe"]
quite unusual.
in second example, after predicate trying find self-or-descendant city
element, element not exist in xml provided. if xml correct change second query to:
<result>{ doc("mondial.xml")//country[encompassed/@continent = "europe"] }</result>
you might consider using eq
instead of =
here doing atomic comparison. leave read that. priscialla walmsley's xquery book excellent resource if getting started xquery.
Comments
Post a Comment