tags:

views:

80

answers:

1

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?

+2  A: 

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.

jarnbjo