psini has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks,
I have a tree generated by XML::Parser(Style => 'tree'). My program modifies it and needs to serialize it back to a XML file.
sub serialize { my $writer=shift; my $tag=shift; my $value=shift; if ($tag eq 0) { $writer->characters($value); } else { $writer->startTag($tag,%{$value->[0]}); shift(@$value); while (@$value) { my $t=shift(@$value); my $v=shift(@$value); serialize($writer,$t,$v); } $writer->endTag(); } }
I am currently using XML::Writer and this 20 lines recursive sub to do the serialization. I'm sure I'm reinventing the wheel here but I can't find a module doing this.
Any hint?
TIA
Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."
Back to
Seekers of Perl Wisdom