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::DOM
  • XML::XPathEngine

πŸ’– AUTHOR πŸ’–

Michel Rodriguez, mirod@cpan.org

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