Jdom:对于小型xml处理就好
dom4j:对于大文件优与jdom,故选择dom4j
使用xpath,需要引入jar包:jaxen-1.1.6.jar
使用xpath获得element
List<Attribute> selectNodes = document.selectNodes("/resultList/result/stepList/step");
使用xpath获得Attribute
List<Attribute> selectNodes = document.selectNodes("/resultList/result/stepList/step/@elapsedTime");
System.out.println(selectNodes.get(1).getData());
dom4j:对于大文件优与jdom,故选择dom4j
SAXReader reader = new SAXReader();
Document document = reader.read(new File("E:/F/wks_alms_custom_dep/CapitalSimulExplain/temp/result.xml"));
Element element = root.element("result");
Element stepListElement = element.element("stepList");
List<Element> stepElements = stepListElement.elements("step");
使用xpath,需要引入jar包:jaxen-1.1.6.jar
使用xpath获得element
List<Attribute> selectNodes = document.selectNodes("/resultList/result/stepList/step");
使用xpath获得Attribute
List<Attribute> selectNodes = document.selectNodes("/resultList/result/stepList/step/@elapsedTime");
System.out.println(selectNodes.get(1).getData());