XML::MyXML - A simple XML module
Version 0.066
use XML::MyXML qw(tidy_xml xml_to_object); my $xml = "<item><name>Table</name><price><usd>10.00</usd><eur>8.50</eur></price></item>"; print tidy_xml($xml); my $obj = xml_to_object($xml); print "Price in Euros = " . $obj->path('price/eur')->value; $obj->simplify is hashref { item => { name => 'Table', price => { usd => '10.00', eur => '8.50' } } }
tidy_xml, object_to_xml, xml_to_object, simple_to_xml, xml_to_simple
Returns the XML string in a tidy format (with tabs & newlines)
Creates an 'XML::MyXML::Object' object from the raw XML provided
Creates an XML string from the 'XML::MyXML::Object' object provided
Produces a raw XML string from an array reference such as this one: [ thing => [ name => 'John', location => [ city => 'New York', country => 'U.S.A.' ] ] ]
Produces a very simple hash object from the raw XML string provided. An example hash object created thusly is this: { thing => { name => 'John', location => { city => 'New York', country => 'U.S.A.' } } }
Since the object created is a hashref, duplicate keys will be discarded. WARNING: This function only works on very simple XML strings, i.e. children of an element may not consist of both text and elements (child elements will be discarded in that case)
Returns the tag specified by the path as an XML::MyXML::Object object. When there are more than one tags with the specified name in the last step of the path, it will return all of them as an array.
When the tag represented by the $obj object has only text contents, returns those contents as a string
Returns a very simple hashref, like the one returned with &XML::MyXML::xml_to_simple. Same restrictions and warnings apply.
Returns the XML string of the object, just like calling &object_to_xml( $obj )
Returns the XML string of the object in tidy form, just like calling &tidy_xml( &object_to_xml( $obj ) )
Alexander Karelas, <karjala at karjala.org>
<karjala at karjala.org>
Please report any bugs or feature requests to bug-xml-myxml at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=XML-MyXML. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-xml-myxml at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc XML::MyXML
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/XML-MyXML
CPAN Ratings
http://cpanratings.perl.org/d/XML-MyXML
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=XML-MyXML
Search CPAN
http://search.cpan.org/dist/XML-MyXML
Copyright 2006 Alexander Karelas, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install XML::MyXML, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::MyXML
CPAN shell
perl -MCPAN -e shell install XML::MyXML
For more information on module installation, please visit the detailed CPAN module installation guide.