OpenThought::XML2Hash
use OpenThought::XML2Hash;
my $xml = '<xml><packet type="example"/></xml>'; my $hash = xml2hash( $xml );
OpenThought::XML2Hash is a no nonsense XML parser. It's an attempt to create a hash out of an XML packet as fast as possible. It takes an XML file or string and returns a hash of the appropriate nested depth based on the contents of the XML.
XML2Hash only looks at XML attributes, start tags, end tags, and the character data in between. It ignores most everything else, including comments, namespaces, and CDATA sections. This is a feature :-) One day, it'll probably do something constructive with comments.
With the limited set of XML processed, and the methods used to process it, XML2Hash appears to be almost twice as fast as any other module on CPAN which can make a hash out of XML.
This is the main function of the XML2Hash package. It accepts two arguments, only the first is required. It then returns the hash representation of your data.
Path to the XML file, or a string containing an XML packet.
Don't process the XML data until reaching this element. If you specify element "foo" here, foo will not be used as a hash key, but the next XML tag to be found will be. It makes sense when you use it :-)
This would typically be used when you have a large XML file, but you only need a small subsection as a hash. By passing in the b<element> argument, you'd save some CPU time by only processing the data you care about.
Returns a reference to a hash containing the contents of the XML file, with each XML element being a hash key. The hash is nested just as your XML was.
OpenThought, XML::Parser::Expat
Eric Andreychek (eric at openthought.net)
OpenThought::XML2Hash is Copyright (c) 2000-2003 by Eric Andreychek.
None known.
1 POD Error
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
To install OpenThought::XML2Hash, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenThought::XML2Hash
CPAN shell
perl -MCPAN -e shell install OpenThought::XML2Hash
For more information on module installation, please visit the detailed CPAN module installation guide.