通用XML处理工具
package com.metarnet.Execution.test;import org.apache.log4j.Logger;import com.metarnet.Execution.util.XMLUtil;public class TestXml {public static final Logger logger=Logger.getLogger(TestTelnet.class);public static void main(String[] args) {XMLUtil util = XMLUtil.getXML("F:\\Test.xml");util.createXML();util.addNode("name", "闫帆");util.addNode("Telephone", "18691090812");util.addNodeAttribute("//name", "ID", "123");System.out.println(util.SelectNodeValue("//name"));System.out.println(util.SelectNodeString("//name", "ID"));util.addNode("www", "Metar");util.addNode("text", "闫帆");util.addNode("//www","Telephone", "18691090812");util.alterNode("//text", "修改测试");System.out.println(util.SelectNodeValue("//www"));util.removeNode("//Telephone");util.removeNode("//text","//Telephone");}}
-----------------------------------程序员 闫帆原创---------------------------------------
转载请注明原创人信息 程序员 闫帆yanfanvip