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();