开发者

Do XPath on a Node with Java

I have someNode and I'd like to do XPath on it like this:

XPath xpath = XPathFactory.newInstance().newXPath();
XPathExpression expr = xpath.compile("//name");
Object result = expr.evaluate(SOMETHING_ELSE, XPathConstants.NODE);

How can I turn someNode to SOMETHING_ELSE and do my开发者_高级运维 XPath?


What is wrong with Object result = expr.evaluate(someNode, XPathConstants.NODE);? The XPathExpression takes an Object as first parameter, and you can pass any reference to a node, element or attribute of your XML document.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜