此前苦苦寻找的方法:
1 java.io.StringWriter out = new java.io.StringWriter();2 XMLWriter xw = new XMLWriter (out, new OutputFormat (" ", true, "GB2312"));3 xw.write(document);4 String xmlstring = out.toString();5 return xmlstring;