/**
* Evaluates the specified expression on the specified node and returns the
* result as a String.
*
* @param expression
* The Xpath expression to evaluate.
* @param node
* The node on which to evaluate the expression.
*
* @return The result of evaluating the specified expression, or null if the
* evaluation didn't return any result.
*
* @throws XPathExpressionException
* If there are any problems evaluating the Xpath expression.
*/
private static String evaluateAsString(String expression, Node node,
XPath xpath) throws XPathExpressionException {
if (isEmpty(node)) {
return null;
}
if (!expression.equals(".")) {
/*
* If the expression being evaluated doesn't select a node, we want
* to return null to distinguish between cases where a node isn't
* present (which should be represented as null) and when a node is
* present, but empty (which should be represented as the empty
* string).
*
* We skip this test if the expression is "." since we've already
* checked that the node exists.
*/
if (asNode(expression, node, xpath) == null) {
return null;
}
}
String s = xpath.evaluate(expression, node);
return s.trim();
}
XpathUtils.java 文件源码
java
阅读 21
收藏 0
点赞 0
评论 0
项目:aws-sdk-java-v2
作者:
评论列表
文章目录