Programming

Document Object Reference Manual

XML DOM evaluate() Method

Definition and Usage

The evaluate() method calculates an XPath expression.

Syntax:xpathTextevaluate(contextNodeevaluate(namespaceURLMapperevaluate(resultTypeevaluate(The possible values of the result type are constants defined by the XPathResult object.,
) Description
xpathText Parameters
contextNode The string representing the XPath expression to be calculated.
namespaceURLMapper

The node in the document corresponding to the expression to be calculated.

A function that maps a namespace prefix to a full namespace URL.

resultType

If such a mapping is not needed, it is null.

Specifies the type of the object expected as a result, using XPath to force the result type.

The possible values of the result type are constants defined by the XPathResult object.

result

A reusable XPathResult object;

If you need to create a new XPathResult object, it is null.

represents a return value of an expression calculated based on the given Context node XPathResult object.

throws

if xpathText containing syntax errors, or if the result of the expression cannot be converted to the desired resultTypeor if the expression contains namespaceURLMapper An unresolvable namespace, or if contextNode An exception will be thrown if the method has an incorrect type or if it is not related to this document.

Description

This method calculates the specified XPath expression based on the given Context node and returns an XPathResult object, which is determined by the type to determine what the result type should be. If you want to calculate an expression multiple times, use Document.createExpression() to compile the expression into XPathExpression Objectand then use the evaluate() method of XPathExpression.

IE does not support this API. See Node.selectNodes() and Node.selectSingleNode() for an IE-specific alternative method.

See

Document Object Reference Manual