XML::Handler::2Simple - SAX => XML::Simple handler
my $h = XML::Handler::2Simple->new( %xml_simple_options, DataHandler => \&sub_to_handle_result, ## optional ); my $p = XML::SAX::ParserFactory->parser( Handler => $h ); my $data_struct = $p->parse_uri( $file );
This module accepts a SAX stream and converts it in to a Perl data structure using XML::Simple. The resulting object can be passed to a subroutine and is returned after the parse.
For example, here's a SAX machine that outputs all of the records in a record oriented XML file:
use XML::Handler::2Simple; use XML::SAX::Machines qw( ByRecord ); use IO::Handle; ## Needed because LibXML uses it without loading it use Data::Dumper; $Data::Dumper::Indent = 1; ## Clean up Data::Dumper's output a wee bit $Data::Dumper::Terse = 1; $Data::Dumper::Quotekeys = 1; ByRecord( XML::Handler::2Simple->new( DataHandler => sub { warn Dumper( $_[1] ); }, ) )->parse_file( \*STDIN );
Barrie Slaymaker <barries@slaysys.com>
Copyright 2002, Barrie Slaymaker, All Rights Reserved.
You may use this module under the terms of any of the Artistic, GNU Public, or BSD licenses, your choice.
To install XML::Handler::2Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Handler::2Simple
CPAN shell
perl -MCPAN -e shell install XML::Handler::2Simple
For more information on module installation, please visit the detailed CPAN module installation guide.