Section 25.73. Document.evaluate( ): evaluate an XPath expression


25.73. Document.evaluate( ): evaluate an XPath expression

Firefox 1.0, Safari 2.01, Opera 9:

25.73.1. Synopsis

 XPathResult evaluate(String xpathText,                      Node contextNode,                      Function namespaceURLMapper,                      short resultType,                      XPathResult result)     tHRows DOMException, XPathException 

25.73.1.1. 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.

25.73.1.2. Returns

A XPathResult object representing the evaluation of the expression against the given context node.

25.73.1.3. 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.

25.73.2. 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, use Document.createExpression( ) to compile the expression to an XPathExpression object and then use the evaluate( ) method of XPathExpression.

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

25.73.3. See Also

Document.createExpression( )
Node.selectNodes( )
Node.selectSingleNode( )
XPathExpression
XPathResult



JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net