package com.tianbo.util.XML; import org.dom4j.Attribute; import org.dom4j.Document; import org.dom4j.Node; import java.util.Iterator; import java.util.List; import java.util.Map; public class XMLXPath { public static String getSingleValueByPath(Document document,String path){ Node node = document.selectSingleNode(path); if (node!=null){ String nodeValue = node.getStringValue(); return nodeValue; }else { return null; } } public static List<Node> getPathValues(Document document,String path){ List<Node> nodes= document.selectNodes(path); return nodes; } public static void getPathValues2(Document document,String path){ List list = document.selectNodes(path); for (Iterator it = list.iterator(); it.hasNext();) { Attribute attr = (Attribute) it.next(); //TODO } } }