Reputation: 6181
Is there an standard XQuery function that will return a 'canonical' path for a node?
I mean something like:
/root/element/sub-element[0]
Upvotes: 2
Views: 268
Reputation: 4241
Since XQuery 3.0 there is fn:path($node)
, which does exactly that. If it is not supported by your query processor, you can also use FunctX's functx:path-to-node-with-pos($node)
, which unfortunately does not play well with namespaces.
Upvotes: 4
Reputation: 7853
Yes, in the predicate of a path expression using XQuery you can do something like:
doc("books.xml")/bookstore/book[substring(title,1,5)='Harry']
Hope that helps!
Upvotes: -1