updating element value using java
i hav开发者_开发技巧e 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><![CDATA[test]]></value>
how to avoid these any suggestions.
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");
- http://download.oracle.com/javase/6/docs/api/org/w3c/dom/Document.html#createCDATASection(java.lang.String)
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 :).
Use API Document.createCDATASection to create the CDATA.
精彩评论