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; }