Import XML Workspace Document (Data Management)

Summary

Imports the contents of an XML workspace document into an existing geodatabase.

Usage

  • The Target Geodatabase parameter value must already exist and can be a file, mobile, or enterprise geodatabase. To create an empty geodatabase, use the Create File Geodatabase, Create Mobile Geodatabase, or Create Enterprise Geodatabase tool.

  • If you are importing to a file or enterprise geodatabase and want to use a configuration keyword, you can choose one from the Configuration Keyword drop-down list. In a Python script, you need to know the name of the configuration keyword to use.

  • If the Allow geoprocessing tools to overwrite existing datasets option is unchecked and a data element from the input XML workspace document has the same name as a data element in the Target Geodatabase parameter value, the data element will be imported with a new unique name. If this option is checked, existing datasets will be overwritten. For more information about overwriting tool output, see Geoprocessing options in ArcGIS Pro.

  • The tool messages will include the list of data element names that were imported.

Parameters

LabelExplanationData Type
Target Geodatabase

An existing geodatabase where the contents of the XML workspace document will be imported.

Workspace
Import File

The input XML workspace document file containing geodatabase contents to be imported. The file can be an .xml file or a compressed .zip or .z file containing the .xml file.

File
Import Options
(Optional)

Specifies whether both data (feature class and table records, including geometry) and schema will be imported, or only the schema will be imported.

  • Import data and schemaData and schema will be imported. This is the default.
  • Import schema onlyOnly the schema will be imported.
String
Configuration Keyword
(Optional)

The geodatabase configuration keyword to be applied if the Target Geodatabase parameter value is an enterprise or file geodatabase.

String

Derived Output

LabelExplanationData Type
Updated Target Geodatabase

The updated geodatabase.

Workspace

arcpy.management.ImportXMLWorkspaceDocument(target_geodatabase, in_file, {import_type}, {config_keyword})
NameExplanationData Type
target_geodatabase

An existing geodatabase where the contents of the XML workspace document will be imported.

Workspace
in_file

The input XML workspace document file containing geodatabase contents to be imported. The file can be an .xml file or a compressed .zip or .z file containing the .xml file.

File
import_type
(Optional)

Specifies whether both data (feature class and table records, including geometry) and schema will be imported, or only the schema will be imported.

  • DATAData and schema will be imported. This is the default.
  • SCHEMA_ONLYOnly the schema will be imported.
String
config_keyword
(Optional)

The geodatabase configuration keyword to be applied if the target_geodatabase parameter value is an enterprise or file geodatabase.

String

Derived Output

NameExplanationData Type
out_geodatabase

The updated geodatabase.

Workspace

Code sample

ImportXMLWorkspaceDocument example 1 (Python window)

The following Python window script demonstrates how to use the ImportXMLWorkspaceDocument function in immediate mode.

import arcpy
arcpy.management.ImportXMLWorkspaceDocument("C:/Data/Target.gdb", 
                                            "C:/Data/StJohnsData.xml", 
                                            "SCHEMA_ONLY", "DEFAULTS")
ImportXMLWorkspaceDocument example 2 (stand-alone script)

The following Python script demonstrates how to use the ImportXMLWorkspaceDocument function in a stand-alone script.

# Name: ImportXMLWorkspaceDocument.py
# Description: Import the contents of an XML workspace document into a target 
#              geodatabase. 

# Import system modules
import arcpy

# Set local variables
target_gdb = "c:/data/Target.gdb"
in_file = "c:/data/StJohnsData.xml"
import_type = "SCHEMA_ONLY"
config_keyword = "DEFAULTS"

# Run ImportXMLWorkspaceDocument
arcpy.management.ImportXMLWorkspaceDocument(target_gdb, in_file, import_type, 
                                            config_keyword)

Related topics