this might be clearer in an `_upload_instance(xml_file)` function, everything from here to the except clause