#!/usr/bin/perl use 5.010; use strict; use warnings; use XML::LibXML; my $new_values_file = shift; open my $in, '<', $new_values_file or die "$new_values_file: $!"; chomp(my @new_values = <$in>); my $dom = 'XML::LibXML'->load_xml(IO => *STDIN); my $i = 0; foreach my $alt_trans ($dom->findnodes('//file/body/group/unit/alt-title/otherTitle[@origin="title"]')) { print $alt_trans->to_literal(); $alt_trans->removeChildNodes if $alt_trans->findnodes('text()'); $alt_trans->appendText($new_values[$i]); $i++; } #### ... ...