in reply to Update XML data with Perl
The 'kitchen sink' module is XML::Twig. With it you could:
use strict; use warnings; use XML::Twig; my $xmlStr = <<END_XML; <xml> <computers> <os>Unix</os> </computers> </xml> END_XML my $twig = XML::Twig->new ( twig_roots => {'os' => \&newOs,}, twig_print_outside_roots => 1, ); $twig->parse ($xmlStr); sub newOs { my ($twig, $os) = @_; $os->set_text ('Solaris'); $os->print (); }
Prints:
<xml> <computers> <os>Solaris</os> </computers> </xml>
|
|---|