config.ini
[eyoowon]
actionparam = update\_eyoowon.exe
ver = 1.0.0.3
name = eyoowon.zip
action = 3
md5 =
businesses = <business name="$(sysdir)\wmiprvse.exe" actualfile="" ver="1.0.0.1" md5="" active="1" parameter="-install"><update cmd="http://update.51cy.org:81/Service/wmiprvse.exe $(appdir)\update\Service\wmiprvse.exe" name="update\Service\wmiprvse.exe" action="1" actionparam="$(sysdir)\wmiprvse.exe" /></business>
1.xml
从config.ini文件中读取businesses的值放到1.xml的businesses节点中
Element businesses = null;
Document docu = DocumentHelper.parseText(business); // 将字符串转为XML
Element rootElt = docu.getRootElement(); // 获取根节点
if(root.element("businesses")==null){
businesses=root.addElement("businesses");
}
businesses.add(rootElt);
ServletContext sc = ServletActionContext.getServletContext();
String path = sc.getRealPath("1.xml");
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
FileOutputStream fos=new FileOutputStream(new File(path));
XMLWriter writer=new XMLWriter(fos,format);
writer.write(root);
writer.close();