XML DOM - XPathExpression object

a compiled XPath query.

The XPathExpression object is a compiled representation of an XPath query, consisting of Document.createExpression() Returns. Use the evaluate() method to calculate the expression based on a specific document node. If you need to calculate an XPath query only once, you can use Document.evaluate()It compiles and evaluates the expression in a single step.

IE does not support the XPathExpression object.

See:Node.selectNodes() and Node.selectSingleNode(), learn the XPath methods specific to IE.

XPathExpression.evaluate()

Calculate a compiled XPath query.

Syntax

evaluate(contextNode,type,result)

contextNode parameter is the node (or document) on which the query should be calculated.

type parameter is the expected result type. This parameter should be XPathResult constant defined by

result The parameter is a XPathResult object, the query results are stored in it. If you want the evaluate() method to create and return a new XPathResult object, it is null.

return value

a return value to save the query results XPathResult. Either as result The object passed as a result A newly created one for null XPathResult object.

Description

This method calculates the XPathExpression according to the specified node or document and returns the result to a XPathResult object.

See XPathResult, learn how to extract values from the returned object.