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";