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!

how to insert ascii characters using dom

843834Mar 22 2008 — edited Mar 22 2008
I am having a tough time inserting ascii values in to xml text content

i search for a regular space and try insert a non breaking space in my xml whic is basically �

Infact I want to insert the ascii value of a non breaking space or for that matter ascii value of any character, I am using dom level 2.

in the code the actual replace ment string is the ascii code, somehow when I click preview, it actually shows the space instead showing the what I have in my actual code, so i had to separate in the ascii and ; in my code snippet that follows
String text = nl.item(i).getNodeValue();
            System.out.println(text);
            String newText  = text.replaceAll("\\s", "� followed by a ;");
            nl.item(i).setNodeValue(newText)
it actually inserts
 
in the xml code for the xml document and literally "&#160 followed by ;" appears in my document when viewed from a browser, all I am trying to do is replace a given character with an ascii value using dom. All i tried to do was replace a regular space with a non breaking space.

&nbsp won't work either, infact i tried ascii values for other characters too, i end up having the ascii value in the tag when i view the finished document in a browser.

Please help

Edited by: jaks4u on Mar 22, 2008 2:23 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 19 2008
Added on Mar 22 2008
2 comments
307 views