Select to view content in your preferred language

Python script to export Geodatabase to XML Workspace ?

3571
6
02-18-2011 10:17 AM
MiguelGarriga1
Deactivated User
Anyone know if there is a Python script to export a Geodatabase (data and schema) to an XML Workspace Document ?

I need to export several Personal Geodatabases to File Geodatabases.  The ArcCatalog Export > XML Workspace Document tool takes a long time for large Geodatabases, and I'd like to Automate this to run several exports overnight.
Tags (2)
0 Kudos
6 Replies
LoganPugh
Frequent Contributor
Currently the only way that I know of to do this using Python is through comtypes and ArcObjects. See this thread (and linked threads) on GIS StackExchange for an introduction and some useful wrapper code: http://gis.stackexchange.com/questions/80/how-do-i-access-arcobjects-from-python

You could also try this .NET console application (may have to adjust source code for license initialization in ArcGIS 10 and recompile). It's a command line app that you could then call from Python, once for each GDB you want to export. http://resources.arcgis.com/gallery/file/arcobjects-net-api/details?entryID=A9BACE36-1422-2418-3452-...

If you can wait for ArcGIS 10.1, there are supposedly going to be new import and export XML tools, according to this ArcGIS Ideas post: http://ideas.arcgis.com/ideaView?id=087300000008G2xAAE
0 Kudos
PeterWilson
Frequent Contributor
Hi Miguel

I wanted to find out from you if you came right in being able to automate (python script) to export a geodatabase schema and data to XML?

Regards
0 Kudos
MiguelGarriga1
Deactivated User
Hi Miguel

I wanted to find out from you if you came right in being able to automate (python script) to export a geodatabase schema and data to XML?

Regards


I did not pursue the python automation of XML export.  Exported the data manually instead.
0 Kudos
PeterWilson
Frequent Contributor
Thanks Miguel

Regards
0 Kudos
JosephArmbruster
Occasional Contributor
If you wanted pure-Python automation through the File Geodatabase API, this is now possible.  See my post:
http://libjoe.blogspot.com/2014/02/python-wrapper-for-esri-file.html

You can also check out the project page here:
https://code.google.com/p/file-geodatabase-api-python-wrapper/

Enjoy!
Joseph Armbruster
0 Kudos
JohnDye
Deactivated User
Am I missing something here?

Why wouldn't you be able to use the 'ExportXMLWorkspaceDocument_management()' function in arcpy?

To export the schema with the data contents, just set the export_type argument to 'Data'.

MyGDB = r"C:\MyGIS\MyGDB.gdb"
ResultXML = r"C:\MyGIS\MyGDBXML.xml"
arcpy.ExportXMLWorkspaceDocument_management (MyGDB, ResultXML, "DATA", "BINARY", METADATA)


If you need to do this for a bunch of GDBs, then just populate them all in a list and loop through the list.
0 Kudos