views:

27

answers:

1

Hi,

I need to send XML response from my GAE servlet. What I already have is: - An instance of org.w3c.dom.Document populated with data - HttpServletResponse (that gives me either a PrintWriter or a ServletOutputStream)

If XMLSerializer were whitelisted in GAE, I could finish the work. ..but it's not.

My question is: How to cook the food from these ingredients? (without 3rd party libraries please)

Thanks for any hints.

+1  A: 

Have you tried:

Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, ENCODING);
transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", INDENT);
StreamResult result = new StreamResult(writer);
DOMSource source = new DOMSource(document);
transformer.transform(source, result);
Steven
Steven, you're such a great savior!