in reply to Update XML data with Perl
Gotta pick up some xpath but this is a great, fast, flexible, robust way to do it; XML::LibXML.
use XML::LibXML; my $doc = XML::LibXML->new->parse_fh(\*DATA); my ( $os ) = $doc->findnodes('//os[text()="Unix"]'); my $content = $os->firstChild(); $content->setData("Solaris"); print $doc->serialize(1); __DATA__ <xml> <computers> <os>Unix</os> </computers> </xml>
Ta.
<?xml version="1.0"?> <xml> <computers> <os>Solaris</os> </computers> </xml>
|
|---|