I am reading and writing Java Properties files in XML format. Many of the property value have HTML embedded, which developers wrap in [[CDATA elements like so:
<entry key="foo"><![CDATA[
<b>bar</b>
]]></entry>
However, when I use the Java API to load these properties and later write them back to XML, it doesn’t wrap these entries in CDATA elements, but rather escapes the tags, like so:
<entry key="foo"><b>bar</b></entry>
Are these two formats equivalent? Am I introducing any potential problems by replacing CDATA with escaped tags?
Not equivalent, but the text value you get by calling
getText()is the same.However, I would suggest you to abandon
Propertiesin favor of real XML parsed by JAXB – it’s awesome, you’ll like it.Didn’t found any nice one, so at least these:
Object -> XML: here
Sun’s verbose tutorial: http://java.sun.com/webservices/docs/2.0/tutorial/doc/JAXBUsing.html