  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Document converting < and > characters into < and > | Document converting < and > characters into < and > 2006-10-16 - By Heise, Robert
Back Hello,
Im wondering if anybody can assist or has run into this issue before:
I have an external source which is returning xml. When I obtain that xml via BufferedReader the xml looks like this:
<RIBCL><RESPONSE STATUS="0x0000" MESSAGE='No error' /></RIBCL>
However when I create a new JDOM Document and add content like this:
Element root = new Element("responses"); root.addContent(inputLine);
And then output the Document via:
Document doc = new Document(root); doc.setDocType(new DocType("base64")); System.out.println(doc.getDocType()); Format format = Format.getPrettyFormat(); XMLOutputter serializer = new XMLOutputter(format); String xml = serializer.outputString(doc); System.out.println(xml);
Where there appears to be a valide "<" or ">" tag it is replacing with < >
<responses><RIBCL><RESPONSESTATUS="0x0000"MESSAGE='Noerror'/> ;<
How do I get make sure the string content with < and > tags are not replaced with > and < symbols?
Thanks in advance Rob
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii"> <META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1"> <TITLE>Document converting < and > characters into &lt; and &gt;< /TITLE> </HEAD> <BODY> <!-- Converted from text/rtf format -->
<P><FONT SIZE=2 FACE="Arial">Hello,</FONT> <BR>
<BR><FONT SIZE=2 FACE="Arial">Im wondering if anybody can assist or has run into this issue before:</FONT> </P>
<P><FONT SIZE=2 FACE="Arial">I have an external source which is returning xml. When I obtain that xml via BufferedReader the xml looks like this:</FONT> </P>
<P><FONT SIZE=2 FACE="Arial"><RIBCL><RESPONSE STATUS ="0x0000" MESSAGE='No error' /></RIBCL></FONT> </P>
<P><FONT SIZE=2 FACE="Arial">However when I create a new JDOM Document and add content like this:</FONT> </P>
<P><FONT SIZE=2 FACE="Arial">Element root = new Element("responses"); </FONT>
<BR><FONT SIZE=2 FACE="Arial">root.addContent(inputLine);</FONT> </P>
<P><FONT SIZE=2 FACE="Arial">And then output the Document via:</FONT> </P>
<P><FONT SIZE=2 FACE="Arial">Document doc = new Document(root);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> doc .setDocType(new DocType("base64"));</FONT>
<BR><FONT SIZE=2 FACE="Arial"> System .out.println(doc.getDocType());</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> Format format = Format.getPrettyFormat();</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> XMLOutputter serializer = new XMLOutputter(format);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> String xml = serializer.outputString(doc);</FONT>
<BR><FONT SIZE=2 FACE="Arial"> </FONT>
<BR><FONT SIZE=2 FACE="Arial"> System .out.println(xml);</FONT> </P>
<P><FONT SIZE=2 FACE="Arial">Where there appears to be a valide "<" ; or ">" tag it is replacing with &lt; &gt; </FONT> </P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Courier New"><responses>&lt ;RIBCL&gt;&lt;RESPONSESTATUS="0x0000"MESSAGE='Noerror'/&gt ;&lt;</FONT> </P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Courier New">How do I get make sure the string content with < and > tags are not replaced with &gt and & ;lt symbols?</FONT> </P>
<P><FONT COLOR="#000000" SIZE=2 FACE="Courier New">Thanks in advance</FONT>
<BR><FONT COLOR="#000000" SIZE=2 FACE="Courier New">Rob</FONT> </P>
</BODY> </HTML> __ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |