Code example for StreamResult

0
     * @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();
    } 
}