Solved

special char in XML using dom

Posted on 2004-08-11
4
680 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java string replace 11 79
How do I remove an object from a 3 63
Netbeans and org.apache.commons.lang3 issue 3 55
Java List 4 76
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

759 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