Import XML Workspace Document Fails from ArcPy

02-13-2019 01:55 PM
New Contributor

I am trying to use the distributed geodatabase tools to archive an SDE database to a file geodatabase on a monthly basis.  Workflow is to Export XML Workspace Document from SDE, then Import XML Workspace Document to .gdb.  This works fine in ArcMap, but returns an error from ArcPy.  I tried creating a ModelBuilder to do this, which works fine, but once exported to ArcPy, fails.

Has anyone else run across this issue?  Any ideas on a fix?  Thanks in advance!


Failed to execute. Parameters are not valid.
ERROR 001162: Invalid XML file.
Failed to execute (ImportXMLWorkspaceDocument).


# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# Created on: 2019-02-12 08:57:39.00000
# (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------

# Set the necessary product code
import arceditor

# Import arcpy module
import arcpy

# Local variables:
Connection_to_arcdb__DJ_operations__sde = "Database Connections\\Connection to arcdb (DJ_operations).sde"
DJ_XML_TEST_zip = "C:\\GIS\\SDE_Archive\\"
DJ_XML_TEST_gdb = "C:\\GIS\\SDE_Archive\\DJ_XML_TEST.gdb"
DJ_XML_TEST_gdb__2_ = DJ_XML_TEST_gdb
DJ_XML_TEST_zip__2_ = "C:\\GIS\\SDE_Archive\\"

# Process: Export XML Workspace Document
arcpy.ExportXMLWorkspaceDocument_management(Connection_to_arcdb__DJ_operations__sde, DJ_XML_TEST_zip, "DATA", "BINARY", "METADATA")

# Process: Import XML Workspace Document
arcpy.ImportXMLWorkspaceDocument_management(DJ_XML_TEST_gdb, DJ_XML_TEST_zip__2_, "DATA", "")

2 Replies
Occasional Contributor


I notice that in your import string:

arcpy.ImportXMLWorkspaceDocument_management(DJ_XML_TEST_gdb, DJ_XML_TEST_zip__2_, "DATA", "")

you specify an empty string as the configuration keyword (the fourth argument). Have you tried omitting this entirely? Perhaps an empty string causes the error.

e: I just ran into the same error myself when I tried to import a schema-only XML as DATA. My guess is there is an argument that isn't quite correct for your situation, either the keyword I suggested above or something else.

by Anonymous User
Not applicable


I had this issue and changed:

to be:
and it started working.   
Using arcpy.ImportXMLWorkspaceDocument_management  with ArcPy from Pro 2.7 resulted in a "invalid XML document error".   Its possible I created the xml doc using Pro 2.7 as well so maybe there are changes between versions to the XML schema?
0 Kudos