dom4j 实现 xml文件内容 追加

SAXReader reader = new SAXReader();

Document doc = reader.read(new File("D:\\test.xml"));

Element root = doc.getRootElement();

root.addElement("Content");

OutputFormat format = OutputFormat.createPrettyPrint();

XMLWriter write = new XMLWriter(new FileOutputStream(new File("D:\\test.xml")), format);

write.write(doc);

write.close();

 

你可能感兴趣的:(xml)