I am trying to disallow Null values for specific fields within a gdb. Changing field properties using arcpy.AlterField_managment only changes the properties in the Python object and not in the gdb schema. My workaround is to export an XML workspace document, make the changes using the element tree module in Python, then import the XML back into the gdb. When I go to import the XML back into the gdb ArcGIS gives me this error "Invalid XML file". I removed my code from the equation by just reading the XML workspace document into Python then directly writing it back out. I get the same error, so the issue is not with my code I am using to edit the input XML. Also I tried ET.parse() on the output_xml_file and it parses just fine. So the issue must be that element tree is changing my Esri workspace document when it parses it so that when I try to import back into gdb it doesn't recognize it.
import xml.etree.ElementTree as ET
ET.register_namespace('esri', "http://www.esri.com/schemas/ArcGIS/10.6")
ET.register_namespace('xsi', "http://www.w3.org/2001/XMLSchema-instance")
ET.register_namespace('xs', "http://www.w3.org/2001/XMLSchema")
tree = ET.parse(esri_workspace_doc_xml_file)
tree.write(output_xml_file)
diff -c
)