The list of methods to do XPath Evaluate are organized into topic(s).
Byte
asByte(String expression, Node node) Evaluates the specified XPath expression and returns the result as a Byte.
String byteString = evaluateAsString(expression, node);
return (isEmptyString(byteString)) ? null : Byte.valueOf(byteString);
Byte
asByte(String expression, Node node) Evaluates the specified XPath expression and returns the result as a Byte.
String byteString = evaluateAsString(expression, node);
return (isEmptyString(byteString)) ? null : Byte.valueOf(byteString);
String
convertToXpath(String qname) convert To Xpath
QName name = QName.valueOf(qname);
if ("".equals(name.getNamespaceURI())) {
return "//" + name.getLocalPart();
} else {
return "//*[local-name()='" + name.getLocalPart() + "' and namespace-uri()='" + name.getNamespaceURI()
+ "']";
String
evaluate(File xmlFile, String xPathExpression) evaluate
String result = null;
try {
XPathFactory factory = XPathFactory.newInstance();
XPath xPath = factory.newXPath();
result = xPath.evaluate(xPathExpression, new InputSource(new FileInputStream(xmlFile)));
} catch (Exception ex) {
System.out.println(ex.getMessage());
return result;
boolean
evaluate(Node node, XPathExpression expression) Evaluates the XPath expression in the specified context and returns whether such element was found.
try {
Boolean result = (Boolean) expression.evaluate(node, XPathConstants.BOOLEAN);
return result != null && result;
} catch (XPathExpressionException e) {
return false;
String
evaluate(String path, Node node) evaluate
path = path.trim();
try {
XPath xp = XPathFactory.newInstance().newXPath();
XPathExpression expr = xp.compile(path);
String ret = expr.evaluate(node);
return ret;
} catch (Exception ex) {
throw new RuntimeException(ex);
...
String
evaluateAsString(String expression, Node node) Evaluates the specified expression on the specified node and returns the result as a String.
if (isEmpty(node))
return null;
if (!expression.equals(".")) {
if (asNode(expression, node) == null)
return null;
String s = xpath().evaluate(expression, node);
return s.trim();
...