Reputation: 105
I have the following example html:
<birdbook>
<family page="200">
<family_name>owls</family_name>
<latin_name>Strigiformes<latin_name>
</family>
<family page="312">
<family_name>woodpeckers</family_name>
<latin_name>Picidea<latin_name>
</family>
</birdbook>
I want to do XQuery which returns family names ordered by latin names inside result elements. I tried to do the following:
for $x in doc("birdbook.xml")//family_name
order by $x/latin_name ascending
return
<result>{$x}</result>
Result would be peckers first and then owls. Now I'm still getting owls first. What am I doing wrong?
Upvotes: 0
Views: 37
Reputation: 167516
Use
for $x in doc("birdbook.xml")//family
order by $x/latin_name ascending
return
<result>{$x/family_name}</result>
Upvotes: 1