• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

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.
0
applekanna
Asked:
applekanna
  • 2
1 Solution
 
CEHJCommented:
Try using the entities


String myString = "\"&lt;

etc.
0
 
Venci75Commented:
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
 
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

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now