String xmlReq = generateXML();
xmlReq is the XML string, and I want to print it out in browser, but it doesn't
print it out. But when I go to view|source, then I could see the XML.
any ideas? please help. thanks!!
The browser is trying to interpret the xml tags as HTML tags and, failing to do so, is ignoring them.
The simplest solution is to wrap the XML output in HTML <PRE> tags or in a CSS-styled block with the 'preformatted' attribute set (I forget offhand what the actual name of that attribute is).
Even wrapping the XML string in tags still won't work, a web browser will assume the tags are HTML and render or ignore them. You will need to replace each < and > character to < and > (see the very useful String.replaceAll() method)
Sorry, my reply was automatically escaped. I hope this one works better!
tags won't work, the browser will still try to render tags within the "pre" block and ignore any that aren't HTML.
You need to replace < with &lt; and > with &gt;