92sai has asked for the wisdom of the Perl Monks concerning the following question:
my input ismy $a_type = "alpha"; my $type=$a_type; if($type eq "alpha"){ $file='beta.xml'; } my $twig= XML::Twig->new( pretty_print => 'indented', twig_roots => { name => sub{ my ($p, $name) = @_; $name->set_text( "sai" ); $name->print; $name->purge; return; }, } twig_print_outside_roots => 1, ); $twig->parsefile_inplace( $file, 'bak.*' ); $twig->flush;
and the output i got is<?xml version='1.0' encoding='UTF-8'?> <project> <actions/> <name>Ram</name> <daysToKeep>10</daysToKeep>
you can see the extra lines that i donot want.. in the output. The desired output is<?xml version='1.0' encoding='UTF-8'?> <project> <actions/> <name>Sai</name> <daysToKeep>10</daysToKeep>
<?xml version='1.0' encoding='UTF-8'?> <project> <actions/> <name>Sai</name> <daysToKeep>10</daysToKeep>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to remove spaces after modifying an xml sheet.
by thanos1983 (Parson) on Jun 18, 2015 at 09:48 UTC | |
by 92sai (Novice) on Jun 18, 2015 at 10:53 UTC | |
by Anonymous Monk on Jun 18, 2015 at 10:04 UTC | |
|
Re: How to remove spaces after modifying an xml sheet.
by Anonymous Monk on Jun 18, 2015 at 09:54 UTC | |
by 92sai (Novice) on Jun 18, 2015 at 11:39 UTC | |
by Anonymous Monk on Jun 18, 2015 at 12:02 UTC | |
by 92sai (Novice) on Jun 18, 2015 at 13:31 UTC |