google一下icecloud写的dom4j使用入门

解决方案 »

  1.   

    总觉得应该有个方法把内存中修改过的数据直接写回原xml文件
      

  2.   

    自己封装一下就是了
        public static void writeToFile(Document doc, String filePath,
                String encoding) {
            try {
                OutputFormat fmt = OutputFormat.createPrettyPrint();
                fmt.setEncoding(encoding);            XMLWriter xmlWriter = new XMLWriter(new OutputStreamWriter(
                        new FileOutputStream(filePath), encoding), fmt);
                xmlWriter.write(doc);
                xmlWriter.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
      

  3.   

    http://www.mycodes.net/soft/4500.htm
    下这个源程序,里面有用dom4j操作xml的bean例子。