#!/usr/bin/perl use strict; use warnings; use XML::LibXML; my $item_list = shift; my $xml = << '__XML__'; __XML__ my $dom = 'XML::LibXML'->load_xml(string => $xml); my ($sets) = $dom->findnodes('/BulkUpdate/UpdateSets'); my ($update) = $sets->findnodes('UpdateSet'); open my $in, '<', $item_list or die $!; while (<$in>) { chomp; my $set; if ($. > 1) { $set = $update->cloneNode(1); $sets->appendChild($set); } else { ($set) = $dom->findnodes('/BulkUpdate/UpdateSets/UpdateSet[last()]'); } my ($cond_prop) = $set->findnodes('where/cond_prop'); $cond_prop->{attrValue} = $_; } print $dom;