# Set up export and import types, import is derived from export type export_dict = {'ArcGIS to FGDC' : 'ARCGIS2FGDC.xml', 'ArcGIS to ISO 19139' : 'ARCGIS2ISO19139.xml', 'FGDC to ArcGIS' : 'FGDC2ESRI_ISO.xml', 'FGDC to ISO 19139' : 'FGDC2ISO19139.xml', 'ISO 19139 to ArcGIS' : 'ISO19139_2ESRI_ISO.xml', 'ArcGIS or ESRI-ISO to ISO 19139' : 'ESRI_ISO2ISO19139.xml'} import_dict = {'ArcGIS to FGDC' : 'FROM_FGDC', 'ArcGIS to ISO 19139' : 'FROM_ISO_19139', 'FGDC to ArcGIS' : 'FROM_ARCGIS', 'FGDC to ISO 19139' : 'FROM_ISO_19139', 'ISO 19139 to ArcGIS' : 'FROM_ESRIISO', 'ArcGIS or ESRI-ISO to ISO 19139' : 'FROM_ISO_19139'}
the first time I run it using FGDC to ARCGIS it works perfect then I run it again on the same object and it blanks out the metadata on that object. Is a translator nessesary?
import arcpy from metadata_ArcGIS_format2 import * # Set env workspace arcpy.env.workspace = r'G:\some\geodatabase.gdb' # Variables export = 'FGDC to ArcGIS' tree = 'Description' # Loop thru gdb to edit metadata for each fc # for fc in arcpy.ListFeatureClasses(): # change all instances of Cedar County to Johnson County # source and target are the same to change original metadata EditMetadataText(fc, fc, 'Cedar County', 'Johnson County', export, tree) print 'Updated metadata for %s' %fc print 'Finished editing metadata for all feature classes'
I have made a script tool to do this. Still testing it, but so far have had no problems with it. It will find and replace text in a metadata file and you can choose specific trees to search through if you want (such as description). This tool could probably use a little more tweaking but it has worked well for what I have used it for. Below is a test showing that I am replacing "Cedar County" with "Johnson County" in the description tree.[ATTACH=CONFIG]22933[/ATTACH][ATTACH=CONFIG]22934[/ATTACH][ATTACH=CONFIG]22935[/ATTACH]Attached is the script tool if you want to check it out.EDIT: I wanted to add that if you know the date text that you want to be replaced you could just set the tree parameter to 'None', and it will parse through the entire xml to replace the 'find string' in all parts of the metadata. So if your last updated date is something like '08-21-2012', you could put that as the find string and set the replace string to '03-25-2013' (although in the xml file usually there are no dashes for the date, it gets formatted like that automatically so you would probably leave the dashes out).
Is there any way in Python to export a specific XML element from an SDE feature class, possibly export it into a temporary XML file then update the value of the element in question, then import it back into the SDE feature class?
Los miembros registrados pueden publicar, seguir actualizaciones y más. ¿Nuevo aquí? Regístrate gratis.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.