I need to modify an XML document and dump it back. I am able to perform this using the XML::Parser in perl however I can't find a way to dump it back. Couldn't find much around writing it back..
one of the dumb implementation
use warnings;
use strict;
use XML::Parser;
use Data::Dumper;
sub char_handler
{
my ($parser, $text) = @_;
$text = #DO SOMETHING HERE WITH THE TEXT
}
my ($file) = @ARGV;
open(FILE,$file);
$xml=<FILE>;
my $parser = new XML::Parser( Style=>"Tree",
Handler => {
Char => \&char_handler
});
my $doc = $parser->parse($xml);
print Data::Dumper->Dump([$doc]);
dumps the XML.