in reply to Update XML data with Perl

You can use XML::Simple not only to read XML, but also to write it back. Though I can't say it's so simple ;)

use strict; use warnings; use XML::Simple; my $xml = '<xml> <computers> <os>Unix</os> </computers> </xml>'; my $ref = XMLin($xml); $ref->{computers}{os} = 'Solaris'; $xml = XMLout( $ref, RootName => 'xml', NoAttr => 1, NoIndent => 1 ); print "$xml\n"; __END__ <xml><computers><os>Solaris</os></computers></xml>

Replies are listed 'Best First'.
Re^2: Update XML data with Perl
by geekman (Initiate) on May 02, 2009 at 15:00 UTC
    Thanks for your answer. But now I have another problem. This works great!!, but how can I do the XMLout to a file? Thanks.

      Just wanted to mention that XML::LibXML has file reading and writing methods (as well as a bunch of other in/out methods):

      $state = $doc->toFile($filename, $format); $doc = $parser->parse_file( $xmlfilename );
      I found how to do this. Thanks.