Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDOM & leading/trailing space characters

843834Jun 15 2009 — edited Jun 17 2009
Hello,
I'm saving an onbject to a xml file using JDOM but the problem I have is that I would like to save also the leading/trailing characters of an attribute. My code is
String myString = "  Hello  ";
Element myElement = new Element("param").setAttribute("name", "myExample").setText();
this will be saved into the xml as
..
<param name="myExample">Hello</param>
..
but I would like to preserve the spaces:
..
<param name="myExample">  Hello  </param>
..
am I supposed to escape them by hand before setting the text to the Element with e.g :
String myString = "  Hello  ";
myString = myString.replaceAll(" ", "#x20");
?

Thanks,
regards,
Tex
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 15 2009
Added on Jun 15 2009
8 comments
534 views