I am using a CDATA section but the text consists of some characters and hence it is getting closed and i am getting parsing exception.
<xyz><![CDATA[\..\..\\..\..\\..\..\\..\..\\..\..\\\boot.ini]]>�</xyz>
i found the below code from some site:
// Add a CDATA section to the root element
Element element = doc.getDocumentElement();
CDATASection cdata = doc.createCDATASection("data");
element.appendChild(cdata);
// If "]]>" appears in the text, two CDATA sections will be written out
cdata = doc.createCDATASection("more]]>data");
element.appendChild(cdata);
The problem in using the above logic is i do not know which element i am reading from DB will contain “]]>” so that i can write two CDATA sections.
Need ur help on this.
Escaping arbitrary text with CDATA sections is error prone because they cannot nest.
Use entity references to escape the text instead.
However, if you really want to use CDATA sections, this section of the Wikipedia page might help.