package com.dom4j;
import java.io.FileOutputStream;
import java.io.IOException;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;
public class CreateNewXML {
public static void main(String[] args) throws IOException {
Document docu = DocumentHelper.createDocument();
Element root = docu.addElement("root");
root.addElement("child").addElement("child1").setText("child1");
root.element("child").addAttribute("gender", "boy");
XMLWriter writer = new XMLWriter(new FileOutputStream("src/Demo.xml"));
writer.write(docu);
writer.close();
}
}
CreateNewXML
最新推荐文章于 2022-11-21 15:12:59 发布