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. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to Re: XML::Generator::PerlData and attributes by jeffa
in thread XML::Generator::PerlData and attributes by dda

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.