有关 org.dom4j.Node.numberValueOf 方法的一个说明
但是,如果节点中存在多个符合 XPath 表达式的节点的话,numberVauleOf 方法实际上只会返回其中第一个节点的值。dom4j 中该方法是通过 org.jaxen.BaseXPath 中的同名方法来实现的,在 jaxen 的文档中,是这样注释的:numberValueOf
public Number numberValueOf(String xpathExpression)
numberValueOf evaluates an XPath expression and returns the numeric value of the XPath expression if the XPath expression results in a number, or null if the result is not a number.
Parameters:
xpathExpression - is the XPath expression to be evaluated
Returns:
the numeric result of the XPath expression or null if the result is not a number.
numberValueOf
public Number numberValueOf(Object node)
throws JaxenException[来源 www.iocblog.net]
Retrieve a number-value interpretation of this XPath expression when evaluated against a given context.
The number-value of the expression is determined per the number(..) core function as defined in the XPath specification. This means that if this expression selects multiple nodes, the number-value of the first node is returned.
Specified by:
numberValueOf in interface XPath
Parameters:
node - the node, node-set or Context object for evaluation. This value can be null.
Returns:
a Double indicating the numeric value of evaluating this expression against the specified context
Throws:
JaxenException - if an XPath error occurs during expression evaluation
文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。