I don't know how to avoid the corrupt .xml It happened to me, but with me it was homing issues.
Create a new .xml file from scratch, and make a backup copy just in case it happens again.
You can also try using one of the automatic .xml backups that Mach3 makes, in the .xmlbackups folder.