static String prettyPrintWithXMLSerializer(Document document) {
        try{
            StringWriter stringWriter = new StringWriter();
            OutputFormat format = new OutputFormat(Method.XML, "UTF-8", true);
            format.setIndent(2);
            XMLSerializer serializer = new XMLSerializer(stringWriter,format);
            serializer.serialize(document);
            return stringWriter.toString();
        }
        catch(Exception e){
            return "error";
        }
    }