将dom4j格式化为标准的xml字符串

StringWriter writer = new StringWriter();

OutputFormat format = OutputFormat.createPrettyPrint();

format.setEncoding("gb2312");

XMLWriter xmlwriter = new XMLWriter( writer, format );

try {

xmlwriter.write(document);

} catch (Exception e) {

e.printStackTrace();

}

return writer.toString();

原文地址:https://www.cnblogs.com/houji/p/5210682.html