Debian Codegraph @

README

raw
1 XML-TreePuller
2
3 INSTALLATION
4
5 To install this module, run the following commands:
6
7 perl Makefile.PL
8 make
9 make test
10 make install
11
12 ABOUT
13
14 This module implements a tree oriented XML pull processor using a combination of
15 XML::LibXML::Reader and an object-oriented interface around the output of XML::CompactTree.
16 It provides a fast and convenient way to access the content of extremely large XML documents
17 serially.
18
19 EXAMPLE
20
21 #!/usr/bin/env perl
22
23 use strict;
24 use warnings;
25
26 use XML::TreePuller;
27
28 sub gen_xml {
29 return <<EOF
30
31 <wiki version="0.3">
32
33 <!-- schema says that there is always 1 siteinfo and zero or more page
34 elements follow -->
35 <siteinfo>
36 <sitename>ExamplePedia</sitename>
37 <url>http://example.pedia/</url>
38 <namespaces>
39 <namespace key="-1">Special</namespace>
40 <namespace key="0" />
41 <namespace key="1">Talk</namespace>
42 </namespaces>
43 </siteinfo>
44
45 <page>
46 <title>A good article</title>
47 <text>Some good content</text>
48 </page>
49
50 <page>
51 <title>A bad article</title>
52 <text>Some bad content</text>
53 </page>
54
55 </wiki>
56
57 EOF
58 }
59
60 sub element_example {
61 my $xml = XML::TreePuller->new(string => gen_xml());
62
63 print "Printing namespace names using configuration style:\n";
64
65 $xml->config('/wiki/siteinfo/namespaces/namespace' => 'short');
66
67 while(defined(my $element = $xml->next)) {
68 print $element->attribute('key'), ": ", $element->text, "\n";
69 }
70
71 print "End of namespace names\n";
72 }
73
74 sub subtree_example {
75 my $xml = XML::TreePuller->new(string => gen_xml());
76
77 print "Printing titles using a subtree:\n";
78
79 $xml->config('/wiki/page' => 'subtree');
80
81 while(defined(my $element = $xml->next)) {
82 print "Title: ", $element->get_elements('title')->text, "\n";
83 }
84
85 print "End of titles\n";
86 }
87
88 sub path_example {
89 my $xml = XML::TreePuller->new(string => gen_xml());
90
91 print "Printing path example:\n";
92
93 $xml->config('/wiki/siteinfo', 'subtree');
94 $xml->config('/wiki/page/title', 'short');
95
96 while(my ($matched_path, $element) = $xml->next) {
97 print "Path: $matched_path\n";
98 }
99
100 print "End path example\n";
101 }
102
103
104 element_example(); print "\n";
105 subtree_example(); print "\n";
106 path_example(); print "\n";
107
108 __END__
109
110 Printing namespace names using configuration style:
111 -1: Special
112 0:
113 1: Talk
114 End of namespace names
115
116 Printing titles using a subtree:
117 Title: A good article
118 Title: A bad article
119 End of titles
120
121 Printing path example:
122 Path: /wiki/siteinfo
123 Path: /wiki/page/title
124 Path: /wiki/page/title
125 End path example
126
127
128 SUPPORT AND DOCUMENTATION
129
130 After installing, you can find documentation for this module with the
131 perldoc command.
132
133 perldoc XML::TreePuller
134
135 You can also look for information at:
136
137 RT, CPAN's request tracker
138 http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-TreePuller
139
140 AnnoCPAN, Annotated CPAN documentation
141 http://annocpan.org/dist/XML-TreePuller
142
143 CPAN Ratings
144 http://cpanratings.perl.org/d/XML-TreePuller
145
146 Search CPAN
147 http://search.cpan.org/dist/XML-TreePuller/
148
149
150 COPYRIGHT AND LICENCE
151
152 Copyright (C) 2010 "Tyler Riddle"
153
154 This program is free software; you can redistribute it and/or modify it
155 under the terms of either: the GNU General Public License as published
156 by the Free Software Foundation; or the Artistic License.
157
158 See http://dev.perl.org/licenses/ for more information.
159