Import XML Workspace Document Fails from ArcPy

1708
2
02-13-2019 01:55 PM
ArthurSmith
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!

Error:

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

Code:

# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# XML_from_ModelBuilder.py
# 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.zip"
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\\DJ_XML_TEST.zip"

# 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
NiekGoorman1
Occasional Contributor

Hi,

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:

arcpy.ImportXMLWorkspaceDocument_management
 
to be:
arcpy.management.ImportXMLWorkspaceDocument
 
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