Lalchand
Lalchand

Reputation: 7827

updating element value using java

i have written a java code for updating the element value with the following string

<![CDATA[test]]>

but its saved in the xml file in the following manner

<value>&lt;![CDATA[test]]&gt;</value> 

how to avoid these any suggestions.

Upvotes: 2

Views: 410

Answers (3)

bdoughan
bdoughan

Reputation: 149017

If you are using DOM then you need to create a CDATA node instead of setting the block in a text node.

document.createCDATASection("foo");

Upvotes: 5

Zimbabao
Zimbabao

Reputation: 8240

Use API Document.createCDATASection to create the CDATA.

Upvotes: 0

Daniel
Daniel

Reputation: 28074

It did exactly what you wanted. The stored data represents the String "<![CDATA[test]]>"!

If you use a API to create XML, just don't care for the way the XML is generated, since any parser will be able to parse it correctly. Just store the String "test" and be happy :).

Upvotes: 0

Related Questions