XML::Generator::PerlData 0.89 review

Download
by rbytes.net on

XML::Generator::PerlData is a Perl extension for generating SAX2 events from nested Perl data structures. SYNOPSIS use XML::G

License: GPL (GNU General Public License)
File size: 13K
Developer: Kip Hampton
0 stars award from rbytes.net

XML::Generator::PerlData is a Perl extension for generating SAX2 events from nested Perl data structures.

SYNOPSIS

use XML::Generator::PerlData;
use SomeSAX2HandlerOrFilter;

## Simple style ##

# get a deeply nested Perl data structure...
my $hash_ref = $obj->getScaryNestedDataStructure();

# create an instance of a handler class to forward events to...
my $handler = SomeSAX2HandlerOrFilter->new();

# create an instance of the PerlData driver...
my $driver = XML::Generator::PerlData->new( Handler => $handler );

# generate XML from the data structure...
$driver->parse( $hash_ref );

## Or, Stream style ##

use XML::Generator::PerlData;
use SomeSAX2HandlerOrFilter;

# create an instance of a handler class to forward events to...
my $handler = SomeSAX2HandlerOrFilter->new();

# create an instance of the PerlData driver...
my $driver = XML::Generator::PerlData->new( Handler => $handler );

# start the event stream...
$driver->parse_start();

# pass the data through in chunks
# (from a database handle here)
while ( my $array_ref = $dbd_sth->fetchrow_arrayref ) {
$driver->parse_chunk( $array_ref );
}

# end the event stream...
$driver->parse_end();
and you're done...

XML::Generator::PerlData provides a simple way to generate SAX2 events from nested Perl data structures, while providing finer-grained control over the resulting document streams.
Processing comes in two flavors: Simple Style and Stream Style:

In a nutshell, 'simple style' is best used for those cases where you have a a single Perl data structure that you want to convert to XML as quickly and painlessly as possible. 'Stream style' is more useful for cases where you are receiving chunks of data (like from a DBI handle) and you want to process those chunks as they appear. See PROCESSING METHODS for more info about how each style works.

Requirements:
Perl

XML::Generator::PerlData 0.89 keywords