Solved

special char in XML using dom

Posted on 2004-08-11
4
679 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 50 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

740 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