Well, i have been trying to get this to work for 30 minutes
now with no luck. I even pulled in one the test files from
the distro and
it didn't "work":
use strict;
use warnings;
use XML::Generator::PerlData;
use XML::Handler::YAWriter;
use IO::File;
use Data::Dumper;
my $handler = XML::Handler::YAWriter->new(
Output => new IO::File (">-"),
Pretty => {
PrettyWhiteIndent => 1,
PrettyWhiteNewline => 1,
CompactAttrIndent => 1,
},
);
my $pd = XML::Generator::PerlData->new(Handler => $handler);
my %attrmap = ( zoix => ['bar', 'norkel'] );
my $obj = SomeObj->new();
my %opts = (
attrmap => \%attrmap,
skipelements => ['freep'],
namespacemap => {'http://localhost/ns/default' => [ 'document' ]},
keymap => {baz => 'norkel'},
);
$pd->parse( $obj, %opts );
package SomeObj;
use strict;
sub new {
my $proto = shift;
my %args = @_;
my %sh = (foo => 'foobie',
bar => 'barbie',
baz => 'bazly'
);
my @sa = ( 'one', 'two', 'three' );
my @sa2 = ( 'four', 'five', 'six' );
my @sa3 = ( 'seven', 'eight', 'nine' );
my %hashofrefs = (array => \@sa,
hash => \%sh
);
my @aofas = ( \@sa, \@sa2, \@sa3 );
my %sh2 = (foo => 'foobie',
zoix => \%sh,
bar => 'barbie',
hork => \@sa,
baz => 'bazly',
bibble => \%hashofrefs,
freep => 'funk',
fibble => \@aofas
);
$args{yick} = \%sh2;
my $class = ref( $proto ) || $proto;
my $self = bless( \%args, $class );
return $self;
}
There could be a bug in this version (0.89) or we could
both be missing how to properly use this module. My
suggestion is to (well, always explain
what you
are trying to accomplish first!) pick another module. From
the docs, it appears that this one may have been designed
to be used with a database. If that is the case, then try
XML::Generator::DBI instead. I wrote a tutorial
on it over at
XML::Generator::DBI Tutorial. Best of luck. :)