README
1
2XML::Mini Perl Module - Homepage and latest version:
3
4 http://minixml.psychogenic.com
5
6INSTALLATION:
7
83 Methods are available:
9
10- CPAN
11 # perl -MCPAN -e 'install XML::Mini'
12
13- Local
14 perl Makefile.PL
15 make
16 make test
17 su ; make install
18
19- Simple (no need for root priv)
20
21 Since XML::Mini is a pure Perl implementation, you can simply
22 tar zxvf XML-Mini-XXX.tar.gz
23 mv lib/XML /path/to/destination
24
25 and then, in your code, use:
26
27 #!/usr/bin/perl
28 use lib '/path/to/destination';
29 use XML::Mini::Document;
30
31 # ... create and parse XML!
32
33
34
35NAME
36 XML::Mini - Stand-alone, pure Perl implementation of the MiniXML
37 XML generator and parser interface (http://minixml.psychogenic.com).
38
39SYNOPSIS
40 use XML::Mini::Document;
41
42 ############# Generate XML ###############
43
44 # Create a new XML::Mini::Document
45
46 my $newDoc = XML::Mini::Document->new();
47
48 # Creating XML can be done easily by using a hash ref:
49 my $h = {
50 'spy' => {
51 'id' => '007',
52 'type' => 'SuperSpy',
53 'name' => 'James Bond',
54 'email' => 'mi5@london.uk',
55 'address' => 'Wherever he is needed most',
56 },
57 };
58
59 $newDoc->fromHash($h);
60
61 # output the XML
62 print $newDoc->toString();
63
64
65 # Or new XML can also be created by manipulating
66 # elements directly:
67
68 my $newDocRoot = $newDoc->getRoot();
69
70 # create the <? xml ?> header
71 my $xmlHeader = $newDocRoot->header('xml');
72 # add the version
73 $xmlHeader->attribute('version', '1.0');
74
75 my $person = $newDocRoot->createChild('person');
76
77 my $name = $person->createChild('name');
78 $name->createChild('first')->text('John');
79 $name->createChild('last')->text('Doe');
80
81 my $eyes = $person->createChild('eyes');
82 $eyes->attribute('color', 'blue');
83 $eyes->attribute('number', 2);
84
85 # output the document
86 print $newDoc->toString();
87 # ...
88
89 ############# Parse XML ###############
90 # Parse existing XML string
91 my $xmlDoc = XML::Mini::Document->new();
92
93 $xmlDoc->parse($XMLString);
94 # or
95 $xmlDoc->parse('/path/to/file.xml');
96 # or
97 $xmlDoc->parse(*INPUTFILEHANDLE);
98
99 # Now we can fetch elements:
100
101 my $part = $xmlDoc->getElementByPath('partsRateReply/part');
102
103 my $partId = $part->attribute('id');
104
105 my $price = $partList->getElement('price');
106
107 print "Part $partId costs: " . $price->getValue() . "\n";
108
109DESCRIPTION
110 XML::Mini is a set of Perl (and PHP) classes that allow you to access
111 XML data and create valid XML output with a tree-based hierarchy of
112 elements.
113
114 It provides an easy, object-oriented interface for manipulating XML
115 documents and their elements. It is currently being used to send
116 requests and understand responses from remote servers in Perl or PHP
117 applications.
118
119 XML::Mini does not require any external libraries or modules.
120
121 The XML::Mini.pm module includes a number of variable you may use to
122 tweak XML::Mini's behavior. These include:
123
124 $XML::Mini::AutoEscapeEntities - when greater than 0, the values set for
125 nodes are automatically escaped, thus $element->text('4 is > 3') will
126 set the contents of the appended node to '4 is > 3'. Default setting
127 is 1.
128
129 $XML::Mini::IgnoreWhitespaces - when greater than 0, extraneous
130 whitespaces will be ignored (maily useful when parsing). Thus <mytag>
131 Hello There </mytag> will be parsed as containing a text node with
132 contents 'Hello There' instead of ' Hello There '. Default setting is 1.
133
134 $XML::Mini::CaseSensitive - when greater than 0, element names are
135 treated as case sensitive. Thus, $element->getElement('subelement') and
136 $element->getElement('SubElement') will be equivalent. Defaults to 0.
137
138Class methods
139 escapeEntites TOENCODE
140
141 This method returns ToENCODE with HTML sensitive values (eg '<', '>',
142 '"', etc) HTML encoded.
143
144 Log MESSAGE
145
146 Logs the message to STDERR
147
148 Error MESSAGE
149
150 Logs MESSAGE and exits the program, calling exit()
151
152
153
154AUTHOR
155
156
157Copyright (C) 2002-2008 Patrick Deegan, Psychogenic Inc.
158
159Programs that use this code are bound to the terms and conditions of the GNU GPL (see the LICENSE file).
160If you wish to include these modules in non-GPL code, you need prior written authorisation
161from the authors.
162
163
164This library is released under the terms of the GNU GPL version 3, making it available only for
165free programs ("free" here being used in the sense of the GPL, see http://www.gnu.org for more details).
166Anyone wishing to use this library within a proprietary or otherwise non-GPLed program MUST contact psychogenic.com to
167acquire a distinct license for their application. This approach encourages the use of free software
168while allowing for proprietary solutions that support further development.
169
170
171 LICENSE
172
173 XML::Mini XML parser/generator package.
174 Copyright (C) 2002-2008 Patrick Deegan
175 All rights reserved
176
177 XML::Mini is free software: you can redistribute it and/or modify
178 it under the terms of the GNU General Public License as published by
179 the Free Software Foundation, either version 3 of the License, or
180 (at your option) any later version.
181
182 XML::Mini is distributed in the hope that it will be useful,
183 but WITHOUT ANY WARRANTY; without even the implied warranty of
184 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
185 GNU General Public License for more details.
186
187 You should have received a copy of the GNU General Public License
188 along with XML::Mini. If not, see <http://www.gnu.org/licenses/>.
189
190
191
192
193SEE ALSO
194
195 http://minixml.psychogenic.com
196
197