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
31 return a list of nodes found by $path.
32
33 findnodes_as_string($path)
34
35 return the nodes found reproduced as XML. The result is not guaranteed
36 to be valid XML though.
37
38 findvalue($path)
39
40 return the concatenation of the text content of the result nodes
41
42 exists($path)
43
44 return true if the given path exists.
45
46 matches($path)
47
48 return true if the node matches the path.
49
51 XML::DOM
52
53 XML::XPathEngine
54
56 Michel Rodriguez, mirod@cpan.org
57
59 Copyright 2003 by Michel Rodriguez
60
61 This library is free software; you can redistribute it and/or modify it
62 under the same terms as Perl itself.
63
64
65
66perl v5.8.8 2008-04-14 XPath(3)