**XMLWriter类: writer(): 写出一个document对象到xml文件
添加:
DocumentHelper.createDocument(); 添加文档对象
addElement(name) 添加标签对象
addAttribute(name,value) 添加属性对象**
public static void main(String[] args) throws Exception {
/**
* 创建一个空xml文档,并添加相关标签和属性
*/
Document doc = DocumentHelper.createDocument();
Element conListElem = doc.addElement("file-list");
Element conElem = conListElem.addElement("file");
conElem.addElement("name");
conElem.addAttribute("id", "003");
conElem.addAttribute("name","jsp");
OutputStream out = new FileOutputStream("F:/copy.xml");
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("utf-8");
XMLWriter writer = new XMLWriter(out,format);
writer.write(doc);
}