Refactor XML copy to use utility method copy_xml