private String toXml ( Node node ) { try { Transformer transformer = TransformerFactory . newInstance ( ) . newTransformer ( ) ; StreamResult result = new StreamResult ( new StringWriter ( ) ) ; DOMSource source = new DOMSource ( node ) ; transformer . transform ( source , result ) ; return result . getWriter ( ) . toString ( ) ; } catch ( TransformerException ex ) { throw new IllegalArgumentException ( "Could not transform " + node + " to XML" , ex ) ; } }
Returns the XML node as String of XML .