.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "XML::Mini 3pm" .TH XML::Mini 3pm "2022-10-15" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XML::Mini \- Perl implementation of the XML::Mini XML create/parse interface. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XML::Mini::Document; \& \& use Data::Dumper; \& \& \& ###### PARSING XML ####### \& \& # create a new object \& my $xmlDoc = XML::Mini::Document\->new(); \& \& # init the doc from an XML string \& $xmlDoc\->parse($XMLString); \& \& # You may use the toHash() method to automatically \& # convert the XML into a hash reference \& my $xmlHash = $xmlDoc\->toHash(); \& \& print Dumper($xmlHash); \& \& \& # You can also manipulate the elements like directly, like this: \& \& # Fetch the ROOT element for the document \& # (an instance of XML::Mini::Element) \& my $xmlRoot = $xmlDoc\->getRoot(); \& \& # play with the element and its children \& # ... \& my $topLevelChildren = $xmlRoot\->getAllChildren(); \& \& foreach my $childElement (@{$topLevelChildren}) \& { \& # ... \& } \& \& \& ###### CREATING XML ####### \& \& # Create a new document from scratch \& \& my $newDoc = XML::Mini::Document\->new(); \& \& # This can be done easily by using a hash: \& my $h = { \& \*(Aqspy\*(Aq => { \& \*(Aqid\*(Aq => \*(Aq007\*(Aq, \& \*(Aqtype\*(Aq => \*(AqSuperSpy\*(Aq, \& \*(Aqname\*(Aq => \*(AqJames Bond\*(Aq, \& \*(Aqemail\*(Aq => \*(Aqmi5@london.uk\*(Aq, \& \*(Aqaddress\*(Aq => \*(AqWherever he is needed most\*(Aq, \& }, \& }; \& \& $newDoc\->fromHash($h); \& \& \& \& # Or new XML can also be created by manipulating \& #elements directly: \& \& my $newDocRoot = $newDoc\->getRoot(); \& \& # create the header \& my $xmlHeader = $newDocRoot\->header(\*(Aqxml\*(Aq); \& # add the version \& $xmlHeader\->attribute(\*(Aqversion\*(Aq, \*(Aq1.0\*(Aq); \& \& my $person = $newDocRoot\->createChild(\*(Aqperson\*(Aq); \& \& my $name = $person\->createChild(\*(Aqname\*(Aq); \& $name\->createChild(\*(Aqfirst\*(Aq)\->text(\*(AqJohn\*(Aq); \& $name\->createChild(\*(Aqlast\*(Aq)\->text(\*(AqDoe\*(Aq); \& \& my $eyes = $person\->createChild(\*(Aqeyes\*(Aq); \& $eyes\->attribute(\*(Aqcolor\*(Aq, \*(Aqblue\*(Aq); \& $eyes\->attribute(\*(Aqnumber\*(Aq, 2); \& \& # output the document \& print $newDoc\->toString(); .Ve .PP This example would output : .PP .Vb 12 \& \& \& \& \& John \& \& \& Doe \& \& \& \& .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" XML::Mini is a set of Perl classes that allow you to access \s-1XML\s0 data and create valid \s-1XML\s0 output with a tree-based hierarchy of elements. The MiniXML \s-1API\s0 has both Perl and \s-1PHP\s0 implementations. .PP It provides an easy, object-oriented interface for manipulating \s-1XML\s0 documents and their elements. It is currently being used to send requests and understand responses from remote servers in Perl or \s-1PHP\s0 applications. An XML::Mini based parser is now being tested within the \s-1RPC::XML\s0 framework. .PP XML::Mini does not require any external libraries or modules and is pure Perl. If available, XML::Mini will use the Text::Balanced module in order to escape limitations of the regex-only approach (eg \*(L"cross-nested\*(R" tag parsing). .PP The Mini.pm module includes a number of variables you may use to tweak XML::Mini's behavior. These include: .PP \&\f(CW$XML::Mini::AutoEscapeEntities\fR \- when greater than 0, the values set for nodes are automatically escaped, thus \&\f(CW$element\fR\->text('4 is > 3') will set the contents of the appended node to '4 is > 3'. Default setting is 1. .PP \&\f(CW$XML::Mini::IgnoreWhitespaces\fR \- when greater than 0, extraneous whitespaces will be ignored (maily useful when parsing). Thus Hello There will be parsed as containing a text node with contents 'Hello There' instead of ' Hello There '. Default setting is 1. .PP \&\f(CW$XML::Mini::CaseSensitive\fR \- when greater than 0, element names are treated as case sensitive. Thus, \f(CW$element\fR\->getElement('subelement') and \f(CW$element\fR\->getElement('SubElement') will be equivalent. Defaults to 0. .SH "Class methods" .IX Header "Class methods" .SS "escapeEntites \s-1TOENCODE\s0" .IX Subsection "escapeEntites TOENCODE" This method returns ToENCODE with \s-1HTML\s0 sensitive values (eg '<', '>', '"', etc) \s-1HTML\s0 encoded. .SS "Log \s-1MESSAGE\s0" .IX Subsection "Log MESSAGE" Logs the message to \s-1STDERR\s0 .SS "Error \s-1MESSAGE\s0" .IX Subsection "Error MESSAGE" Logs \s-1MESSAGE\s0 and exits the program, calling \fBexit()\fR .SS "ignoreDeepRecursionWarning" .IX Subsection "ignoreDeepRecursionWarning" XML::Mini uses deep recursion on big \s-1XML\s0 docs, this is normal. But the warnings are a pain. \&\f(CW$XML::Mini::IgnoreDeepRecursionWarnings\fR is set to \s-1TRUE\s0 by default, and \fBignoreDeepRecursionWarning()\fR is called by XML::Mini::Document if it is set. To bypass this behavior, .PP .Vb 1 \& use XML::Mini; \& \& $XML::Mini::IgnoreDeepRecursionWarnings = 0; \& \& use XML::Mini::Document; \& \& # ... .Ve .SH "AUTHOR" .IX Header "AUTHOR" Copyright (C) 2002\-2008 Patrick Deegan, Psychogenic Inc. .PP Programs that use this code are bound to the terms and conditions of the \s-1GNU GPL\s0 (see the \s-1LICENSE\s0 file). If you wish to include these modules in non-GPL code, you need prior written authorisation from the authors. .PP This library is released under the terms of the \s-1GNU GPL\s0 version 3, making it available only for free programs (\*(L"free\*(R" here being used in the sense of the \s-1GPL,\s0 see http://www.gnu.org for more details). Anyone wishing to use this library within a proprietary or otherwise non-GPLed program \s-1MUST\s0 contact psychogenic.com to acquire a distinct license for their application. This approach encourages the use of free software while allowing for proprietary solutions that support further development. .SS "\s-1LICENSE\s0" .IX Subsection "LICENSE" .Vb 3 \& XML::Mini::Element module, part of the XML::Mini XML parser/generator package. \& Copyright (C) 2002\-2008 Patrick Deegan \& All rights reserved \& \& XML::Mini is free software: you can redistribute it and/or modify \& it under the terms of the GNU General Public License as published by \& the Free Software Foundation, either version 3 of the License, or \& (at your option) any later version. \& \& XML::Mini is distributed in the hope that it will be useful, \& but WITHOUT ANY WARRANTY; without even the implied warranty of \& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the \& GNU General Public License for more details. \& \& You should have received a copy of the GNU General Public License \& along with XML::Mini. If not, see . .Ve .SH "SEE ALSO" .IX Header "SEE ALSO" XML::Mini::Document, XML::Mini::Element .PP http://minixml.psychogenic.com