NAME

OpenThought::XML2Hash

SYNOPSIS

use OpenThought::XML2Hash;

my $xml = '<xml><packet type="example"/></xml>'; my $hash = xml2hash( $xml );

DESCRIPTION

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.

FUNCTIONS

hashref xml2hash( xml, [element] )

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.

Parameters
xml

Path to the XML file, or a string containing an XML packet.

element (optional)

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

    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.

SEE ALSO

OpenThought, XML::Parser::Expat

AUTHOR

Eric Andreychek (eric at openthought.net)

COPYRIGHT

OpenThought::XML2Hash is Copyright (c) 2000-2003 by Eric Andreychek.

BUGS

None known.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 327:

You forgot a '=back' before '=head1'

You forgot a '=back' before '=head1'