I am working on a python script to create some feature classes from dbf tables. As part of the script I would like to pull two values (FGDC "publication date" and ArcGIS Spatial Reference ArcGIS Coordiante System "Projection") from the metadata of a linear referencing feature class and write them to a field in the feature class. I've looked at some of the modules that parse .xml files, but the linear referencing feature class doesn't have a standalone .xml. Below is the part of the script where i'd like to pull and calculate the values.
#Pull COORDSYS and MAPVERSION from RCI Metadata
#Calculate Values for Coordsys, Mapsource, MapVersion, publish date, CAR xfer date, coord xfer date
today = datetime.date.today()
pub_date = today.strftime("%m/%d/%y")
arcpy.CalculateField_management(input,"COORDSYS",XXX,"PYTHON_9.3")
arcpy.CalculateField_management(input,"MAPSOURCE",mapsource_ON,"PYTHON_9.3")
arcpy.CalculateField_management(input,"MAPVERSION",XXX,"PYTHON_9.3")
arcpy.CalculateField_management(input,"DTPUBLISHE",pub_date,"PYTHON_9.3")
arcpy.CalculateField_management(input,"DTCARXTRCT",pulldate,"PYTHON_9.3")
arcpy.CalculateField_management(input,"DTCOORDXTR",pub_date,"PYTHON_9.3")
Best Answer
is creating a standalone .xml file for the feature class an option? ... for instance a temporary XML, which you delete extracting the information you need?
If yes, you might want to look into the arcpy command "XSLTransform_conversion". To get acquainted with it, look into ArcToolbox: Conversion Tools > Metadata toolset. The arcpy command only calls this tool.
Essentially, this tool allows you to convert metadata from a format to another. In your case, you could expose the feature class metadata into a XML file using the tool's parameter "XSL sheet" called "exact copy of". These XSL sheets are available in your ArcGIS install folder, under ..\Metadata\Stylesheets\gpTools. As it says, this particular XSL sheet will make NO modification to the contents on the feature class metadata, it will only export it into a XML file.
ESRI help on this tool is available here, and here is further help on the metadata toolset.