Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> How to get Attributes in XML Output
I've seen plenty of examples that show how to query tables and get
results such as the following, where the data is shown in elements:
<ROWSET>
<ROW num="1">
<CUSTOMER>
<CUSTOMERID>1044</CUSTOMERID>
<FIRSTNAME>Paul</FIRSTNAME>
<LASTNAME>Astoria</LASTNAME>
<HOMEADDRESS>
<STREET>123 Cherry Lane</STREET>
<CITY>SF</CITY>
<STATE>CA</STATE>
<ZIP>94132</ZIP>
</HOMEADDRESS>
</CUSTOMER>
</ROW>
</ROWSET>
My question is, how do I get the data in attributes? Is it even possible? I'm familiar with using FOR XML in MS SQL, but have not come across a similar procedure in Oracle 8i or 9i. An example of the output using the above example would be:
<ROWSET>
<ROW num="1">
<CUSTOMER CUSTOMERID="1044" FIRSTNAME="Paul" LASTNAME="Astoria">
<HOMEADDRESS STREET="123 Cherry Lane" CITY="SF" STATE="CA"
ZIP="94132">
</HOMEADDRESS>
</CUSTOMER>
</ROW>
</ROWSET>
I hope that makes sense. Thanks.
Ryan Received on Tue Apr 15 2003 - 11:40:10 CDT