Java 怎么评估xpath节点

2019年7月29日20:55:28Java 怎么评估xpath节点已关闭评论 328 477字阅读1分35秒

1.简介

Java 怎么评估xpath节点?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */



import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Node;

public class Main {
    public static Node evaluateXpathNode(Node rootNode, String xPathQuery)
            throws XPathExpressionException {
        XPath xPath = XPathFactory.newInstance().newXPath();
        return (Node) xPath.compile(xPathQuery).evaluate(rootNode,
                XPathConstants.NODE);
    }
}

 
编程十万个怎么办