in reply to Re^4: copy XML elements from one file to another
in thread copy XML elements from one file to another

All issues stem from the same cause; namely, the change you made in the for loop needs to be also done for your File0. Change:

write_xml_content($key_file, $source_file_for{$key_file}, $out_fh, ' ' + x 4);

to

open my $in_fh, '<', $source_file_for{$key_file}; write_xml_content($key_file, $in_fh, $out_fh, ' ' x 4); close $in_fh;

-- Ken