Here is the perl script I have written to modify the particular value from the xml file — neo-datasource.xml
.
I can print the modified xml contents in the output console using ->toString
, but I wish to have these changes to be reflected in the same xml file called neo-datasource.xml
instead of printing it in console.
Could you please share your ideas?
use strict;
use warnings;
use XML::Twig;
my $twig = XML::Twig->new( keep_spaces => 1 );
$twig->parsefile('C:UsersIBM_ADMINDesktopdbautomate
eo-datasource.xml');
my ($class_string) = $twig->findnodes('//var[@name="d1new1d1"]/struct[@type="coldfusion.server.ConfigMap"]/var[@name="password"]/string');
$class_string->set_text('NoDatabase');
print $twig->toString;
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…