换种方法,我个人觉得你的方法太复杂,自己写的还好点

解决方案 »

  1.   

    public  static  void  set()
       {
         try {
         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         DocumentBuilder builder =factory.newDocumentBuilder();
         Document doc = builder.parse("d:\\DataBase\\reg.xml");
        transFactory=TransformerFactory.newInstance();
                      Transformer transformer=transFactory.newTransformer();
                      DOMSource source=new DOMSource(doc);
                      File newXML=new File("d:\\reg.xml");
                      FileOutputStream os=new FileOutputStream(newXML);
                      StreamResult result=new StreamResult(os);
                      transformer.transform(source,result);
       }
    生成的XML文件,只有根元素和头,这是怎么回事啊
      

  2.   

    问题解决了。只是生成的格式问题,内容我没有看见而已