Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

special char in XML using dom

Posted on 2004-08-11
4
Medium Priority
?
683 Views
Last Modified: 2010-07-27
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
Comment
Question by:applekanna
  • 2
4 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 11771569
Try using the entities


String myString = "\"&lt;

etc.
0
 
LVL 9

Accepted Solution

by:
Venci75 earned 200 total points
ID: 11771617
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
 
LVL 3

Author Comment

by:applekanna
ID: 11779978
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
 
LVL 3

Author Comment

by:applekanna
ID: 11780335
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question