日期:2014-05-20 浏览次数:20750 次
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
DOMSource source = new DOMSource(document);
transformer.setOutputProperty(OutputKeys.ENCODING, "GBK");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
File file = new File(mPath + "index.xml");
file.createNewFile();
String filename = file.getAbsolutePath();
PrintWriter pw = new PrintWriter(new FileOutputStream(filename));
StreamResult result = new StreamResult(pw);
transformer.transform(source, result);