use warnings;
use strict;
use XML::XPath;
my $xml = <<'ENDXML';
9990
true
/efs/dist/tpcommon/itrstemplates/latest/common/templates/equities.xml
10001
true
/efs/dist/itrs/tools/latest/common/templates/global_authentication.xml
ENDXML
my $xp = XML::XPath->new(xml => $xml);
my $nodes = $xp->find('//includes/include');
for my $include ($nodes->get_nodelist) {
for my $p ($xp->findnodes('./priority', $include)) {
my $priority = $p->string_value;
$p->removeChild($_) for $p->getChildNodes;
$p->appendChild( XML::XPath::Node::Text->new($priority+1) );
}
}
my ($root) = $xp->findnodes('/');
print $root->toString, "\n";
####
use XML::Twig;
open my $ofh, '>', \my $outxml or die $!;
my $twig = XML::Twig->new(
twig_print_outside_roots => $ofh,
twig_roots => {
'/includes/include/priority' => sub {
my ($twig, $elt) = @_;
$elt->set_text( $elt->text+1 );
$elt->flush($ofh);
},
} );
$twig->parse($xml);
close $ofh;
print $outxml;