protected static String getHumanReadableXml ( final Node node ) { StringWriter toReturn = new StringWriter ( ) ; try { Transformer transformer = getFactory ( ) . newTransformer ( ) ; transformer . setOutputProperty ( OutputKeys . INDENT , "yes" ) ; transformer . setOutputProperty ( OutputKeys . STANDALONE , "yes" ) ; transformer . transform ( new DOMSource ( node ) , new StreamResult ( toReturn ) ) ; } catch ( TransformerException e ) { throw new IllegalStateException ( "Could not transform node [" + node . getNodeName ( ) + "] to XML" , e ) ; } return toReturn . toString ( ) ; }
Converts the provided DOM Node to a pretty - printed XML - formatted string .