SAXReader saxReader = new SAXReader();
      Document document = saxReader.read(new File("d:/text.xml"));
      Element root = document.getRootElement();
      List list = root.content();
      Element e = DocumentHelper.createElement("test");
      list.add(0, e);
      FileWriter fw = new FileWriter(new File("d:/text.xml"));
      XMLWriter output = new XMLWriter(fw);
      output.write(document);
      output.close();

posted on 2013-06-13 13:51  西城诸葛  阅读(350)  评论(0编辑  收藏  举报