http://community.csdn.net/Expert/topic/3492/3492576.xml?temp=.1601221

解决方案 »

  1.   

    DOM的代码:
    FileWriter writer = new FileWriter(OutPath);        
    OutputFormat outputFormat =new OutputFormat(doc, "GB2312", true);
    XMLSerializer serializer = new XMLSerializer(writer, outputFormat);
    serializer.serialize(doc);
    writer.close();
      

  2.   

    把生成的document对象写成文件:
    XMLOutputter outp = new XMLOutputter();//XMLOutputter为Jdom中的一个类
    outp.output(document, new FileOutputStream("c:/test.xml"));