Adding [CDATA[ element in an XML [message #680729] |
Thu, 04 June 2020 04:56  |
 |
Mark70
Messages: 18 Registered: June 2020
|
Junior Member |
|
|
Hi,
I was asked to generate an XML, extracting data from a table, but adding the [CDATA[ element.
I have done in the following manner:
select XMLTYPE
(
replace(
replace(replace(xmlelement("TAG1",
xmlelement("TAG2",col1),
xmlelement("TAGX",
xmlelement("TAG3",
xmlelement("TAG4",col2)))).extract('/*') ,'/TAGX',']]'),'TAGX','![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?'),
'<]]>',']]>')
)
into XMLdoc
from MYTABLE;
where col1 and col2 are MYTABLE's columns
Is it possible to do in a smarter way instead of using the work-around of the REPLACE?
The result should be this:
<TAG1>
<TAG2> 15 </TAG2>
<![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TAG3>
<TAG4> Rodgers </TAG4>
</TAG3>
]]>
</TAG1>
Thank you!
|
|
|
|
|