XPath(3)
π NAME π
XML::DOM::XPath is a Perl extension that adds XPath support to XML::DOM, using the XML::XPath engine. This page is XPath(3), from the User Contributed Perl Documentation, and bestie, it's literally here to make DOM querying way less painful.
β¨ SYNOPSIS β¨
use XML::DOM::XPath;
my $parser= XML::DOM::Parser->new();
my $doc = $parser->parsefile ("file.xml");
# print all HREF attributes of all CODEBASE elements
# compare with the XML::DOM version to see how much easier it is to use
my @nodes = $doc->findnodes( '//CODEBASE[@HREF]/@HREF');
print $_->getValue, "\n" foreach (@nodes);
πΈ DESCRIPTION πΈ
XML::DOM::XPath allows you to use XML::XPath methods to query a DOM. This is often much easier than relying only on getElementsByTagName.
It lets you use all of the XML::DOM methods. Iconic behavior, no notes.
π METHODS π
Those methods can be applied to a whole dom object or to a node.
π findnodes($path)
Return a list of nodes found by $path.
π§ findnodes_as_string($path)
Return the nodes found reproduced as XML.
ngl, the result is not guaranteed to be valid XML though. π
π findvalue($path)
Return the concatenation of the text content of the result nodes.
π exists($path)
Return true if the given path exists.
π matches($path)
Return true if the node matches the path.
π SEE ALSO π
XML::DOMXML::XPathEngine
π AUTHOR π
Michel Rodriguez, mirod@cpan.org
π COPYRIGHT AND LICENSE π
Copyright 2003 by Michel Rodriguez
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay bye bestie, this XPath(3) page comes from perl v5.42.0 and is dated 2024-03-04 π
β¨π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: perl-XML-DOM-XPath 0.14-bp160.1.11 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms