Commit 99728b0e by WeiCong

优化xmlutil的xpath获取元素函数

parent 648d574e
......@@ -322,9 +322,14 @@ public class XmlUtil {
public static String getXmlNodeValueByXpath(Document document, String path) {
String[] paths = path.split("#");
String xpath = paths[0];
Element curElement = getNodesByXpath(document, xpath, "xpath").get(0);
if (paths.length > 1)
List<Element> lst = getNodesByXpath(document, xpath, "xpath");
if(lst.isEmpty()){
return null;
}
Element curElement = lst.get(0);
if (paths.length > 1){
return curElement.attributeValue(paths[paths.length - 1]);
}
return curElement.getText();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment