Code example for DOMSource

0
            //Setup indenting to "pretty print" 
            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
            serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
 
            Element document = panel.getRootBox().getElement();
            DOMSource source = new DOMSource(document);
            StreamResult output = new StreamResult(System.out);
            serializer.transform(
                    source,
                    output
            ); 
        } catch (TransformerException ex) {
            // this is fatal, just dump the stack and throw a runtime exception 
            ex.printStackTrace();
 
            throw new RuntimeException(ex);
        } 
    } 
}