in reply to if file does not exist

Try:
next unless ( -e "../XML/$id.xml" );
as the frist line of the loop.

Phil