Document doc = DocumentHelper.createDocument();
Element root = doc.addElement("config")
Element files = root.addElement("files");
String configFiles="<files><file name="AdShower123.exe" oriname="update\adshower123.zip" ver="1.0.0.1" md5="" update="http://soft.51cy.org:80/adv/package/adshower.zip" action="3" param="" op="0" optype="3" opcmd="$(appdir)\AdShower.exe" opparam=""/><file name="AdShower123.exe" oriname="update\adshower123.zip" ver="1.0.0.1" md5="" update="http://soft.51cy.org:80/adv/package/adshower.zip" action="3" param="" op="0" optype="3" opcmd="$(appdir)\AdShower.exe" opparam=""/></files>";
Document fileDom=DocumentHelper.parseText(configFiles);
//root.add(fileDom.getRootElement());
//System.out.println("2222222222:"+fileDom.selectNodes("files").toString());
for (Iterator iterator = fileDom.getRootElement().elementIterator(); iterator.hasNext();) {
Element e = (Element) iterator.next();
// files.add(e);
files.add((Element)e.clone());
}
红色是出错的位置,蓝色为正确的写法