Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Narendra.

Asked: October 05, 2016 - 7:43 am UTC

Last updated: October 07, 2016 - 3:09 am UTC

Version: 11g

Viewed 1000+ times

You Asked

Hello Oracle Guruji
Thanks for your support in Advance,
I have one doubt on XMLROOT,
this is my query
ops$tkyte@ORA9IR2>select xmlroot(XMLELEMENT("DriverDescription",'$'||'$'||'s partner payout by PL '||' ='||'>' ||' L2 BU'),VERSION '1.0')as emp
from dual;
Output:
<?xml version="1.0"?>
<DriverDescription>$$s partner payout by PL =&gt; L2 BU</DriverDescription>

But my Output Should be
<?xml version="1.0"?>
<DriverDescription>$$s partner payout by PL => L2 BU</DriverDescription>
like..
Can you please help on this..issue..
but with out xmlroot i'm printing any special characters using xmlelement(NOENTITYESCAPING ..
but my requirement to display with version also..
Please help on this issue...

Thanks For your supporting.

Thanks
Narendra B

and Connor said...

Perhaps look at wrapping it as CDATA ?

SQL> select xmlroot(XMLELEMENT("DriverDescription",xmlcdata('$'||'$'||'s partner payout by PL '||' ='||'>' ||' L2 BU')),VERSION '1.0')as emp from dual;

EMP
----------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<DriverDescription><![CDATA[$$s partner payout by PL  => L2 BU]]></DriverDescription>


Rating

  (3 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

XMLROOT With Special Characters Print

Narendra B, October 06, 2016 - 6:08 am UTC

Hi Team,
This is not i'm excepting..
my output should be like...
<?xml version="1.0"?>
-<AppAllocation>
<EPRID>108489</EPRID>
<AppName>Inventory price protection</AppName>
<Driver>Partner Payout by PL</Driver>
<DriverDescription>$$s partner payout by PL => L2 BU</DriverDescription>
<PeriodStartDate>2016-07-01</PeriodStartDate>
<PeriodEndDate>2016-07-31</PeriodEndDate>
-<Allocation>
<TargetOrg>EGR-EG HP Storage</TargetOrg>
<Value>0.05</Value>
</Allocation>
-<Allocation>
<TargetOrg>EGR-HP Servers</TargetOrg>
<Value>99.95</Value>
</Allocation>
<Comment>$$s partner payout by PL in IPP for month of July 2016 and rolled up to L2 BU</Comment>
</AppAllocation>
the above TargetOrg and Value column shoud be fetch in the select statement.

can you please suggest..
is there any chance to write to ananoyms block or proc.

Thanks in Advance.


Connor McDonald
October 07, 2016 - 3:09 am UTC

From the XML spec

https://www.w3.org/TR/xml/#charsets

"The ampersand character (&) and the left angle bracket (<) must not appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings " &amp; " and " &lt; " respectively. The right angle bracket (>) may be represented using the string " &gt; ", and must, for compatibility, be escaped using either " &gt; " or a character reference when it appears in the string " ]]> " in content, when that string is not marking the end of a CDATA section."