1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| #!/usr/bin/perl
use XML::Twig;
my $filename = './it2.xml';
open(FILE, '>', $filename) || die("impossible open $filename ");
my $t= XML::Twig->new(
twig_roots => { 'top' => \&its, },
twig_print_outside_roots => 1,
);
$t->parsefile( 'its.xml');
sub its
{ my( $t, $price)= @_;
my $currency= $price->{'att'}->{'bat'};
if( $currency eq 'Except')
{ $usd_price= $price->text;
my $euro_price= $usd_price ;
$price->set_text( $euro_price);
$price->set_att( VALUE => 'FINE');
}
$price->print;
} |
Partager