xpath_integer
xpath_integer (expr[, doc])
This function evaluates an XPath expression with respect to a document. This function evaluates expr as a floating-point number, rounds to the nearest integer, and returns that integer.
• expr — A valid XPath expression that can be represented as a number.
Do not use expressions that contain position() or last(). They do not work in this context. Use the preceding-sibling or following-sibling axes instead to achieve the desired results. For example:
◦ count(preceding-sibling::*)=0 will test that the context node is the first child of its parent.
◦ count(preceding-sibling::para)=1 will test that the context node is the second para child of its parent.
◦ count(following-sibling::*)=0 is a viable alternative to position()=last()
• doc — The identifier of the document tree to use as the context node. If omitted or 0, the current document is used.
Non-numeric results are converted to numbers using standard XPath rules:
• Strings are parsed as floating-point numbers.
• Boolean expressions are converted to 1 or 0.
• Node set expressions are first converted to strings, then parsed. A run-time error occurs if the result cannot be represented as an integer.
To handle errors, call this function from within a catch.
Related Topics