HTML::O...valuator(3)

๐Ÿ“ฆ version 0.6.0, in alpine 3.24

okay bestie, you've landed on HTML::O...valuator(3) โ€” the User Contributed Perl Documentation page for HTML::Object::DOM::XPathEvaluator, aka the HTML Object DOM XPathEvaluator Class. buckle up, it's XPath time. ๐Ÿ’…โœจ

๐Ÿ’– NAME ๐Ÿ’–

HTML::Object::DOM::XPathEvaluator โ€” the HTML Object DOM XPathEvaluator Class. that's the name, that's the class, periodt. ๐Ÿ‘‘

๐ŸŽ€ SYNOPSIS ๐ŸŽ€

use HTML::Object::DOM::XPathEvaluator;
my $this = HTML::Object::DOM::XPathEvaluator->new ||
    die( HTML::Object::DOM::XPathEvaluator->error, "\n" );

โญ VERSION โญ

v0.2.0 โ€” that's the version, bestie. ๐Ÿ’–

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

The XPathEvaluator interface is here to compile and evaluate XPath expressions. that's literally its whole thing. โœจ

๐ŸŒธ PROPERTIES ๐ŸŒธ

There are no properties. none. zero. the void. ๐Ÿ’€

๐Ÿ› ๏ธ METHODS ๐Ÿ› ๏ธ

okay, method time. here's the roster:

๐Ÿ’ซ createExpression ๐Ÿ’ซ

This one creates a parsed XPath expression with resolved namespaces. slay. ๐Ÿ’…

Example:

<div>XPath example</div>
<div>Number of &lt;div&gt;s: <output></output></div>

use HTML::Object::DOM;
my $parser = HTML::Object::DOM->new;
my $doc = $parser->parse_data( $html ) || die( $parser->error );
my $evaluator = HTML::Object::DOM::XPathEvaluator->new;
my $expression = $evaluator->createExpression( '//div' );
my $result = $expression->evaluate( $document );
$doc->querySelector( 'output' )->textContent = $result->snapshotLength;

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/XPathEvaluator/createExpression.

๐Ÿ”ฎ createNSResolver ๐Ÿ”ฎ

This always returns undef, since this HTML::Object does not work on XML documents. like, always always. ๐Ÿ™ˆ

Normally, this would adapt any DOM node to resolve namespaces allowing the XPath expression to be evaluated relative to the context of the node where it appeared within the document.

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/XPathEvaluator/createNSResolver.

๐ŸŒˆ evaluate ๐ŸŒˆ

Evaluates an XPath expression string and returns a result of the specified type if possible. iconic. โœจ

Parameters:

  • expression โ€” A string representing the XPath expression to be parsed and evaluated, or an XPath expression object to be evaluated. The latter would be equivalent to:
$xpath_expression->evaluate( $context );

With $context being a node object provided, such as HTML::Object::DOM::Document.

  • contextNode โ€” A Node representing the context to use for evaluating the expression.

Example:

<div>XPath example</div>
<div>Number of &lt;div&gt;s: <output></output></div>

use HTML::Object::DOM;
my $parser = HTML::Object::DOM->new;
my $doc = $parser->parse_data( $html ) || die( $parser->error );
my $evaluator = HTML::Object::DOM::XPathEvaluator->new;
my $result = $evaluator->evaluate( '//div', $doc );
$doc->querySelector( 'output' )->textContent = $result->snapshotLength;

See also Mozilla documentation at https://developer.mozilla.org/en-US/docs/Web/API/XPathEvaluator/evaluate.

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Jacques Deguest <jack@deguest.jp> โ€” the author, the legend. ๐Ÿ’–

๐Ÿฆ„ SEE ALSO ๐Ÿฆ„

HTML::Selector::XPath, HTML::Object::XPath, HTML::Object::XPath::Expr โ€” go read those next, bestie. ๐Ÿ”ฅ

Copyright(c) 2022 DEGUEST Pte. Ltd.

All rights reserved

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

okay that's the whole page. footer check: perl v5.42.2, dated 2026-02-15, and the page name is HTML::O...valuator(3). mwah ๐Ÿ’‹๐Ÿซถ

๐Ÿ“ฆ where this page comes from