@Test public void dome3() throws Exception { DocumentBuilderFactory builderfactory = DocumentBuilderFactory .newInstance(); DocumentBuilder builder = builderfactory.newDocumentBuilder(); Document document = builder.parse("person.xml"); TransformerFactory transformerfactory = TransformerFactory .newInstance(); Transformer transformer = transformerfactory.newTransformer(); DOMSource domsource = new DOMSource(document);//domsource构造数据源 StreamResult result = new StreamResult(new File("persons.xml")); transformer.transform(domsource, result); }
添加回答
举报
0/150
提交
取消