1XPath(3) User Contributed Perl Documentation XPath(3)
2
3
4
6 XML::DOM::XPath - Perl extension to add XPath support to XML::DOM,
7 using XML::XPath engine
8
10 use XML::DOM::XPath;
11
12 my $parser= XML::DOM::Parser->new();
13 my $doc = $parser->parsefile ("file.xml");
14
15 # print all HREF attributes of all CODEBASE elements
16 # compare with the XML::DOM version to see how much easier it is to use
17 my @nodes = $doc->findnodes( '//CODEBASE[@HREF]/@HREF');
18 print $_->getValue, "\n" foreach (@nodes);
19
21 XML::DOM::XPath allows you to use XML::XPath methods to query a DOM.
22 This is often much easier than relying only on getElementsByTagName.
23
24 It lets you use all of the XML::DOM methods.
25
27 Those methods can be applied to a whole dom object or to a node.
28
29 findnodes($path)
30 return a list of nodes found by $path.
31
32 findnodes_as_string($path)
33 return the nodes found reproduced as XML. The result is not guaranteed
34 to be valid XML though.
35
36 findvalue($path)
37 return the concatenation of the text content of the result nodes
38
39 exists($path)
40 return true if the given path exists.
41
42 matches($path)
43 return true if the node matches the path.
44
46 XML::DOM
47
48 XML::XPathEngine
49
51 Michel Rodriguez, mirod@cpan.org
52
54 Copyright 2003 by Michel Rodriguez
55
56 This library is free software; you can redistribute it and/or modify it
57 under the same terms as Perl itself.
58
59
60
61perl v5.36.0 2023-01-20 XPath(3)