Insert empty field CDATA into an XML file using JDOM
Nicola Ace
Greenhorn
Joined: Sep 27, 2010
Posts: 8
posted
0
I'm trying to insert a CDATA field in a xml file using JDOM.
The problem is that the empty field is shown in the xml file like
</content>
and not like
<content></content>
It happens when the field value is like="" (then i get </content>)
If field value is "something" the <content>something</content> is correctly shown
The code i'm using is:
Element content = new Element("content");
CDATA cContenuto = new CDATA(value);
content.addContent(cContenuto);
container.addContent(content);
Someone can help me please?
tanx a lot for the answers!!
Since both forms represent valid XML there should be no problem with either <content/> or <content></content> . Any parser/process that is complaining about <content/> is not XML compliant and a bug report should be raised against it.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Nicola Ace
Greenhorn
Joined: Sep 27, 2010
Posts: 8
posted
0
You have been very kind, tanx for the answer.
I have tryed to validate the xml file and is correct as you said.