Code example for StreamResult

     * @return the transformed XML representation 
     * @throws TransformerException if a transformation error occurs. 
    public static String transform(Node node) throws TransformerException {
        StringWriter writer = new StringWriter();
        StreamResult result = new StreamResult(writer);
        Source source = new DOMSource(node);
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.transform(source, result);
        return writer.toString();
Stop searching for code, let great code find you!  Add Codota to your java IDE