special char in XML using dom

I am using Text to create a text node in DOM

String myString = "\"<c:out value="${status.errorCode}" >"\"
Text txt = document.createTextNode(mystring)

as you can see mystring has " , < , > which are all special chars. When I run my pgm the xml has &lt , &gt etc..
I want to dispaly this string in my XML is it possible to diplay it.
LVL 3
applekannaAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Venci75Connect With a Mentor Commented:
How do you display your XML? Do you use external XML viewer - I guess - no - because otherwise the viewer would show &lt; &gt; &#....; correctly.
0
 
CEHJCommented:
Try using the entities


String myString = "\"&lt;

etc.
0
 
applekannaAuthor Commented:
Escaping the chars did not work,

I did the following, converted the result XML to String and replcae the &lt; with < using
replaceAll("&lt;" "<"); and then wrote to file.

Thanks for ur help
0
 
applekannaAuthor Commented:
WIth more googline This is what i found


OutputFormat formatterLocal = new OutputFormat(document , "ISO-8859-1" , true);
String[] nonEscapingElements = {"script", "option"};
formatterLocal.setNonEscapingElements(nonEscapingElements);

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.