XML::DOM::XPath(3pm)

XML::DOM::XPath3pm

Perl extension to add xpath support to xml::dom, using xml::xpath engine

Usage

  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);

Overview

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.

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

Releases

9 releases since Debian 5.0 (Lenny); the text changed 3 times.

  1. 5.0–8
  2. 9
  3. 10–11
  4. 12–13

Author

Michel Rodriguez, [email protected]

From libxml-dom-xpath-perl 0.14-4 in Debian 13 (Trixie). Parsed by carta from the page's man source.