XML DOM evaluate() methode

Document object reference manual

Definitie en gebruik

De evaluate() methode berekent een XPath-expressie.

Syntax:

evaluate(xpathText,contextNode,namespaceURLMapper,resultType,result)
Parameter Description
xpathText De te berekenen XPath-expressie als string.
contextNode De knopen in het document die overeenkomen met de te berekenen expressie.
namespaceURLMapper

Een functie die een naamruimteprefix koppelt aan een volledige namespace URL.

Als er geen dergelijke koppeling nodig is, is het null.

resultType

Specificeert het type object dat als resultaat wordt verwacht, door middel van een XPath-transformatie om de resultaattype te dwingen.

De mogelijke waarden van het type result zijn de constanten die door het XPathResult object zijn gedefinieerd.

result

Een herbruikbare XPathResult object;

als je een nieuwe XPathResult object wilt maken, is het null.

返值

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

werpt

als xpathText contains syntax errors, or if the result of the expression cannot be converted to the desired resultType,or if the expression contains namespaceURLMapper Unresolvable namespace, or if contextNode It will throw an exception if it has an incorrect type or 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 object,then use the evaluate() method of XPathExpression.

IE does not support this API. See Node.selectNodes() and Node.selectSingleNode() to learn a specific alternative method for IE.

See

Document object reference manual