File: Data.xml
0001
name 1
0002
name 2
0003
name 3
File: Query.xquery
{
for $prod in doc("Data.xml")//car
return (car # {string($prod/id)}
,
{
for $child in $prod/(* except id)
return - {local-name($child)}: {string($child)}
}
)
}
Output:
car # 0001
- name: name 1
car # 0002
- name: name 2
car # 0003
- name: name 3