import org.dom4j.*;
import org.dom4j.io.*;
import java.io.*;
import java.util.Iterator;
public class RW {
//写XML文件
public void Writer() throws IOException {
Document doc = DocumentHelper.createDocument();
Element goods = doc.addElement("goods");//添加根节点
Element phone = goods.addElement("Phone");//根节点下添加Phone节点
Element good1 = phone.addElement("good");//Phone节点下添加good节点
Element brand1 = good1.addElement("品牌");
brand1.setText("三星");//设置节点值
brand1.addAttribute("hot","yes");//设置节点属性
Element price1 = good1.addElement("价格");
price1.setText("3000");
Element good2 = phone.addElement("good");
Element brand2 = good2.addElement("品牌");