Reputation: 57
I need to get all XML elements present in a given file through XQuery. For eg:
<xml>
<a>attr="one"
<b>attr2="in-a"
<c>leaf</c>
</b>
</a>
</xml>
the output should return the following:
<xml>,<a>,<b>,<c>
and if possible in hierarchical manner. And I need to use only XQuery.
Any help appreciated.Thanks.
Upvotes: 3
Views: 900
Reputation: 11244
This should work, where /test.xml
contains the document:
fn:string-join(fn:doc('/test.xml')//*/(concat(name(.), ' > ')))
Upvotes: 4