Re: Extra nesting using DBMS_XMLGEN.getxml and Cursor expression <xmltag_ROW>

From: Gwen Shapira <cshapi_at_gmail.com>
Date: Thu, 1 Dec 2011 17:12:43 -0800
Message-ID: <CAPuboUs0DRKiKT5_ojfkOcBhjfw_fPzL=hwMso5JQJE-qfdGPA_at_mail.gmail.com>



For more fine-grain control over how your document look, you can build XML elements directly, instead of using cursor.

For example:
select xmlelement("numbers",xmlelement("one",1),xmlelement("two",2),xmlelement("three",3)) from dual;

The result is:
<numbers><one>1</one><two>2</two><three>3</three></numbers>

Or for a complete document:
select dbms_xmlgen.getxml('select
xmlconcat(xmlelement("one",1),xmlelement("two",2),xmlelement("three",3))as numbers from dual') from dual;

The result is:
<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <NUMBERS>
   <one>1</one><two>2</two><three>3</three> </NUMBERS>  </ROW>
</ROWSET>

Gwen

On Thu, Dec 1, 2011 at 4:02 PM, Joel Slowik <jslowik_at_cps92.com> wrote:
> I've been searching the documentation and google but I can't seem to
> find what I am looking for.

>

> Let's use this simple query:
>

> select dbms_xmlgen.getxml('select cursor(select ''1'' "one", ''2''
> "two", ''3'' "three" from dual) "numbers" from dual')
> from dual;
>

> the result is:
>

> "<?xml version="1.0"?>
> <ROWSET>
>  <ROW>
>  <numbers>
>   <numbers_ROW>
>    <one>1</one>
>    <two>2</two>
>    <three>3</three>
>   </numbers_ROW>
>  </numbers>
>  </ROW>
> </ROWSET>
> "
>

> Question1: Why was <numbers_row> created when <numbers> is sufficient
> (at least for my purposes)?
>

> Question2: Can I get rid of that extra nesting with the xmlgen package
> or some other package? I'm using regular expressions to do so but it
> seems a bit unreasonable.
>

> Thank you,
> -joel
>
>

> Confidentiality Note: This electronic message transmission is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. If you have received this transmission, but are not the intended recipient, you are hereby notified that any disclosure, copying, distribution or use of the contents of this information is strictly prohibited. If you have received this e-mail in error, please contact Continuum Performance Systems at {203.245.5000} and delete and destroy the original message and all copies.
> --
> http://www.freelists.org/webpage/oracle-l
>
>
--
http://www.freelists.org/webpage/oracle-l
Received on Thu Dec 01 2011 - 19:12:43 CST

Original text of this message