How to get all elements from XML through XQuery

Viewed 666

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.

1 Answers
Related