用javax.xml.transform.TransformerransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.VERSION, "1.0");
transformer.setOutputProperty(OutputKeys.ENCODING, "GB2312");transformer.transform(new DOMSource(dom), new StreamResult(new FileOutputStream(filePath)));