Using the next SQL code, running with Oracle 10:
SELECT xmlserialize
(
document xmlelement
(
"Response", xmlforest
(
'00' AS "ReturnCode"
), xmlagg
(
xmlelement
(
"Students", xmlelement
(
"Student", xmlforest
(
'Some 1' AS "Name",
'1' AS "Id"
)
), xmlelement
(
"Student", xmlforest
(
'Some 2' AS "Name",
'2' AS "Id"
)
)
)
)
) AS CLOB INDENT
) FROM dual
... I get this XML structure:
<Response>
<ReturnCode>00</ReturnCode>
<Students>
<Student>
<Name>Some 1</Name>
<Id>1</Id>
</Student>
<Student>
<Name>Some 2</Name>
<Id>2</Id>
</Student>
</Students>
</Response>
... but, I want to get this one (removing the 'root' element):
<ReturnCode>00</ReturnCode>
<Students>
<Student>
<Name>Some 1</Name>
<Id>1</Id>
</Student>
<Student>
<Name>Some 2</Name>
<Id>2</Id>
</Student>
</Students>
Several attemps like this didnt work. Is mandatory to have a root element?:
SELECT xmlserialize
(
document xmlforest
(
'00' AS "ReturnCode"
), xmlagg
(
xmlelement
(
"Students", xmlelement
(
"Student", xmlforest
(
'Some 1' AS "Name",
'1' AS "Id"
)
), xmlelement
(
"Student", xmlforest
(
'Some 2' AS "Name",
'2' AS "Id"
)
)
)
) AS CLOB INDENT
) FROM dual
Any help will be appreciated. (This is just a simplification of something more complex I need to do in some project).