evaluate() is declared to return Object.
Actual return type depends on the result of the XPath expression:
number maps to a java.lang.Double
string maps to a java.lang.String
boolean maps to a java.lang.Boolean
node-set maps to an org.w3c.dom.NodeList
Second argument specifies the return type you want
XPathConstants.NODESET
XPathConstants.BOOLEAN
XPathConstants.NUMBER
XPathConstants.STRING
XPathConstants.NODE
If the requested conversion can't be made, evaluate() throws an XPathException.