The manakai project


The DOM XPathEvaluator object


The Web::DOM::XPathEvaluator class implements the DOM XPathEvaluator interface. It is a superinterface of the Document interface, but it can also be used as a standalone object.


Following methods are available:

$eval = new Web::DOM::XPathEvaluator

Create a new XPathEvaluator object. [DOMXPATH]

$expr = $eval->create_expression ($string, $resolver)

Parse the specified string as an XPath 1.0 expression and returns it as a new Web::DOM::XPathExpression object. If a code reference or a Web::DOM::XPathNSResolver object is also specified as the optional second argument, it is used as the namespace prefix resolver. [DOMXPATH]

See also "DEPENDENCY" in Web::DOM.

$resolver = $eval->create_ns_resolver ($node)

Create a Web::DOM::XPathNSResolver object with the specified Web::DOM::Node object. [DOMXPATH]

$result = $eval->evaluate ($string, $node, $resolver, $result_type, $result)

Parse and evaluate an XPath 1.0 expression. The first argument is an XPath 1.0 expression to be evaluated. The second argument is the context node (Web::DOM::Node object) used to evaluate the expression. The remainging arguments are optional. The third argument is the namespace prefix resolver, specified as either a code reference or the Web::DOM::XPathResolver object. The fourth argument is the requested result type, specified by one of constants in Web::DOM::XPathResult. The fifth argument is ignored. The method returns the Web::DOM::XPathResult object containing the evaluation result. [DOMXPATH] [DOMPERL]

See also "DEPENDENCY" in Web::DOM.



Document Object Model XPath <>.

DOM XPath <>.

Improving DOM Traversal and DOM XPath <>.

743888 - Replace SVGException and XPathException with DOMException <>.

The definition for the evaluate method MUST be modified as follows:

  partial interface XPathEvaluator {
    XPathResult evaluate(DOMString expression,
                         (Node or Attr) contextNode,
                         XPathNSResolver? resolver,
                         optional unsigned short type = 0,
                         optional object? result = null);

The set of variable bindings MUST be empty. Additional functions MUST NOT be added to the function library.

The evaluate method MUST accept any type of Node as the contextNode argument, i.e. as the context node of the evaluation.

When an evaluation is failed due to a non-syntax non-namespace error, a SyntaxError DOMException MUST be thrown.

The callback this value used when an XPathNSResolver (specified as a function) is invoked is the callback function itself.

If the XPathNSResolver throws an exception, it MUST be catched and act as if the null value is returned.

When the evaluation is initiated, the context position and context size MUST be set to 1.

The evaluate method MUST return a newly created XPathResult object. It MUST NOT return the WRONG_DOCUMENT_ERR or NOT_SUPPORTED_ERR.


manakai's DOM Perl Binding <>.


Web::DOM::Document, Web::DOM::XPathResult.


Wakaba <>.


Copyright 2013 Wakaba <>.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.