package org.hu.jdom;import java.io.File;import java.io.FileOutputStream;import java.io.IOException;import org.jdom.*;import org.jdom.output.XMLOutputter;public class MyJDOM { public static void main(String args[]){ Element root=new Element("root"); Element linkman=new Element("linkman"); Element name=new Element("name"); Element email=new Element("email"); Attribute id=new Attribute("id", "001"); Document doc=new Document(root); name.setText("莉莉"); name.setAttribute(id); email.setText("hid@njd.com"); linkman.addContent(name); linkman.addContent(email); root.addContent(linkman); XMLOutputter out=new XMLOutputter(); try { out.output(doc, new FileOutputStream(new File("D:"+File.separator+"demo.xml"))); } catch (IOException e) { e.printStackTrace(); } }}