Kishore
Kishore

Reputation: 21

XQuery to Order elements(xi:include) in an xml file

Do any one know how to order elements in XML file. I have a course XML file and my course XML file has 5 units which are referenced as xi:include.

Each unit in turn has a unitsequencenumber element. I need to have my course XML returned with unit references ordered based on unitsequencenumber.

Upvotes: 2

Views: 78

Answers (1)

wst
wst

Reputation: 11771

Use order by:

for $e in doc('filename.xml')/unit
order by $e/unitsequencenumber
return $e 

Upvotes: 1

Related Questions