Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert empty field CDATA into an XML file using JDOM

 
Nicola Ace
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!!

 
James Sabre
Ranch Hand
Posts: 781
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Nicola Ace
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have been very kind, tanx for the answer.
I have tryed to validate the xml file and is correct as you said.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's "thanks", please, not "tanx".
 
Nicola Ace
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My apologize.
English is not my motherlanguage.

I was at work and i was tiping as soon as i could.
This is why i used the "contract" form of thanks.

I did not want to offend anyone.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies accepted.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic