I required the following output
<name>Thomas Mapother</name>
<name>Tom Cruise</name>
using the below XML using XQuery FLOWR Expressions.
INSERT INTO XMLO1 VALUES ('<Contact>
<Names>
<Name Type = "Legal">
<First>Thomas</First>
<Middle>T</Middle>
<Last>Mapother</Last>
</Name>
<Name Type = "Stage">
<First>Tom</First>
<Middle>C</Middle>
<Last>Cruise</Last>
</Name>
</Names>
</Contact>')
I tried the below query. But it returns a different output.
SELECT xDoc.query('let $names := Contact/Names/Name
return <name>{
for $x in $names
return ($x/First,$x/Last)}
</name>')
FROM XMLO1