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)
  • Which field are you making NOT NULL? If geometry columns are in the list, then that would cause failure. Your question would be aided by a "context diff" of the pretty-printed before and after documents (the lines around the area where changes occurred, as displayed by diff -c)
    – Vince
    Commented Jul 19, 2018 at 3:21

1 Answer 1


I compared my input and output xml files and element tree is not parsing the file correctly. It is leaving out tags and backslashes and adding spaces where they should not be.

I tried using lxml package and it works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.