File: Data.xml
<order>
<car model="A">
<id>0001</id>
<name language="en">name 1</name>
</car>
<car model="B">
<id>0002</id>
<name language="en">name 2</name>
</car>
<car model="B">
<id>0003</id>
<name language="en">name 3</name>
</car>
</order>
File: Query.xquery
<html>{
for $prod in doc("Data.xml")//car
return (<p>car # {string($prod/id)}</p>,
<ul>{
for $child in $prod/(* except id)
return <li>{local-name($child)}: {string($child)}</li>
}</ul>)
}</html>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<html>
<p>car # 0001</p>
<ul>
<li>name: name 1</li>
</ul>
<p>car # 0002</p>
<ul>
<li>name: name 2</li>
</ul>
<p>car # 0003</p>
<ul>
<li>name: name 3</li>
</ul>
</html>
|