Code example for DOMSource

        return ret;
    public static String xmlNodeToString (Node node) throws Exception {
        // The amount of code required to do simple things in Java is incredible. 
        Source source = new DOMSource(node);
        StringWriter stringWriter = new StringWriter();
        Result result = new StreamResult(stringWriter);
        TransformerFactory factory = TransformerFactory.newInstance();
        Transformer transformer = factory.newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty("{}indent-amount", "2");
        transformer.transform(source, result);
        return stringWriter.getBuffer().toString();
    public static String getErrorMessage (Throwable ex) {
        String errorMessage = ex.getLocalizedMessage();
        if (errorMessage == null)