Name
Document.evaluate( ): evaluate an XPath expression â Firefox 1.0, Safari 2.01, Opera 9:
Synopsis
XPathResult evaluate(StringxpathText
, NodecontextNode
, FunctionnamespaceURLMapper
, shortresultType
, XPathResultresult
) throws DOMException, XPathException
Arguments
-
xpathText
The string representing the XPath expression to evaluate.
-
contextNode
The node in this document against which the expression is to be evaluated.
-
namespaceURLMapper
A function that will map from a namespace prefix to a full namespace URL or
null
if no such mapping is required.-
resultType
Specifies the type of object expected as a result, using XPath conversions to coerce the result. Possible values for
type
are the constants defined by the XPathResult object.-
result
An XPathResult object to be reused or
null
if you want a new XPathResult object to be created.
Returns
A XPathResult object representing the evaluation of the expression against the given context node.
Throws
This method may throw an exception if the
xpathText
contains a syntax error, if
the result of the expression cannot be converted to the desired
resultType
, if the expression contains
namespaces that namespaceURLMapper
cannot resolve, or if contextNode
is of
the wrong type or is not associated with this document.
Description
This method evaluates the specified XPath expression
against the given context node and returns an XPathResult object,
using type
to determine what the result type should be. If you want to evaluate an expression more than once, ...
Get JavaScript: The Definitive Guide, 5th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.