File: Data.xml
0001
name 1
navy black
0002
name 2
0003
name 3
File: Query.xquery
for $car in doc("Data.xml")/order/car
let $name := $car/name
where $car/@model = "B"
order by $name
return $name
Output:
name 2
name 3