How to wrap data in CDATA in XML
390969Nov 26 2003 — edited Jul 14 2004I want to wrap my XML data in CDATA but don't know how to do it. Your help is highly appreciated.
Hre is the piece of code I am using:
sql_statement = "SELECT NEWS_ID, HEADLINE FROM CM_NEWS WHERE NEWS_ID = 101";
conn = dataSource.getConnection();
qry = new OracleXMLQuery(conn, sql_statement);
qry.setRowTag(null);
qry.setDateFormat("MMM dd yyyy");
qry.setEncoding("ISO-8859-1");
qry.setRowsetTag("document");
// Get the XML string
str = qry.getXMLString();
qry.close();
It returns following output:
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<NEWS_ID>101</NEWS_ID>
<HEADLINE>PG.com Success Story</HEADLINE>
</document>
But I want the data to be wraped around <![CDATA[ ]]> as its shown below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<document>
<NEWS_ID><![CDATA[101]]></NEWS_ID>
<HEADLINE><![CDATA[PG.com Success Story]]></HEADLINE>
</document>
Thanks in advance