Skip to content

Instantly share code, notes, and snippets.

@danielestevez
Created February 24, 2015 11:29
Show Gist options
  • Save danielestevez/3faf8b023c478bc9064d to your computer and use it in GitHub Desktop.
Save danielestevez/3faf8b023c478bc9064d to your computer and use it in GitHub Desktop.
Print an org.w3c.dom.Document in console
private static void printXML(final Document responseDoc) throws Exception
{
DOMSource domSource = new DOMSource(responseDoc);
StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter);
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer;
transformer = transformerFactory.newTransformer();
transformer.transform(domSource, streamResult);
System.out.println(stringWriter.toString());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment