Well, after consulting with someone very close with XML::Parser, I took his advice, and switched to XML::Twig ... however I'm only halfway there (generating hash works, generating xml not so good ... i'm confident i'll get help on that one ;)
use Data::Dumper 'DumperX'; use XML::Twig; my $ARGH = q{ <NODE reputation="0" createtime="2001-08-24 08:01:08" id="107642">podm +aster</NODE> }; print DumperX teh_xml_to_hashref($ARGH); print DumperX teh_xml_to_hashref('<o dear="xmltwig">oh how I love thee +</o>'); print DumperX teh_xml_to_hashref('<crack >babies>'); die teh_hashref_to_xml(teh_xml_to_hashref($ARGH)); sub teh_xml_to_hashref { my $xml = shift; my $t = new XML::Twig; $t->safe_parse($xml); return { crack => babies => 6 => 6 } if $@; $t = $t->root; # there is only NODE return { content => $t->text, # cause it's not an att map { $_ => $t->att($_) } $t->att_names, }; } # where is the love? the above in under 10 minutes, but this? sub teh_hashref_to_xml { my $xref = shift; my $t = new XML::Twig; $t->parse('<NODE></NODE>'); $t = $t->root; # there is only NODE $t->set_text($xref->{content}); delete $xref->{content}; for my $att(keys %$xref) { # $t->set_att( $key => $$xref{$key} ); # d'oh, where'em crack babies at?:) $t->set_att( $att => $$xref{$att} ); } return $t->print; } __END__ $VAR1 = { 'reputation' => '0', 'createtime' => '2001-08-24 08:01:08', 'content' => 'podmaster', 'id' => '107642' }; $VAR1 = { 'content' => 'oh how I love thee', 'dear' => 'xmltwig' }; $VAR1 = { 'crack' => 'babies', '6' => 6 }; <NODE createtime="2001-08-24 08:01:08" id="107642" reputation="0">podm +aster</NODE>Died at twig.t line 11.

 

Look ma', I'm on CPAN.


** The Third rule of perl club is a statement of fact: pod is sexy.

In reply to (podmaster: rrrr) Re: XML Simple and Tokeparser troubles by PodMaster
in thread XML Simple and Tokeparser troubles by PodMaster

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.