First try some more to see if you can't make the browser accept the data type as XML and do what you want without making you jump through hoops.
If all else fails, use the <PRE> tag before and after your XML and change '<' to < and '>' to > Duane Morse, Eldorado Computing Inc., Phoenix, Arizona -----Original Message----- From: Ouyang, Jian [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 11:17 AM To: [EMAIL PROTECTED] Subject: Re: Output xml string from a servlet directly to browser and pres erve the xml structure Nic, If I have xml string: <tag1> text1 <tag2> text2 </tag2> <tag2> text3 </tag2> </tag1> I want to display it as it shown in the browser. But if I output this xml string to the browser, I will get: text1text2text3 Is this clear to you? Please help. Thanks. Jian -----Original Message----- From: Nic Ferrier [mailto:[EMAIL PROTECTED]] Sent: Wednesday, March 27, 2002 1:00 PM To: [EMAIL PROTECTED] Subject: Re: Output xml string from a servlet directly to browser and preserve the xml structure "Ouyang, Jian" <[EMAIL PROTECTED]> writes: > I want to be able to use an output method to directly output from > servlet to browser an xml string with the xml tags preserved and the > xml structure clearly presented. (The result should be the same as if > one clicks on an .xml file). I'm not sure what you mean by xml tags preserved. IE does some strange things with XML, it tries to display the document as a DOM. But I'm not sure if that's the behaviour you're after... > I tried to do response.setContentType("text/xml") before print out and > didn't get what I want. (The result is the same as if I use > ("text/html"), ("text/plain")); If you specified the content type as text/plain you'd get just the plain text of the XML but I presume that's not what you want. Nic Ferrier ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
