Has anyone succeeded in programmatically updating metadata in ArcGIS 10? Considering using Python/arcpy but ArcObjects (C# or Python/comtypes) is also a possibility.

I need to update both the FGDC and the ArcGIS-ISO format metadata, and whatever solution is used needs to be able to retain the existing (non-blank) elements along with the added elements, except where they are in conflict in which case the added elements overwrite the existing elements.

We have been struggling with this and solved it by having a simple python library built around the arcobjects metadata functions. It's based on a xml-file where the metadata values have been replaced with keywords. You can use these keywords in your python code to get or set the value of a metadata field. Code woud look something like this:

import dataprocessing
DP = dataprocessing.create()
md = DP.OpenMetadata("C:/MyShapefile.shp") # Works also on geodatabases
myKeyword = "%FGDC.abstract" # Keywords have to start with '%' but the rest is up to you
if md.GetValue(myKeyword) == "Not what I want":
md.SetValue(myKeyword, "New value that suits me better")

The tool can be found here:
http://www.aris.nl/dataprocessing_arcgis and is freely available.
The version on the website is for arcgis 9.3. An arcgis 10 version will be available but it will no longer be free.

(Full disclosure: I work for a dutch government agency where we had the current version of this tool built partly from taxpayers money and partly from time donated by the programmer. That's why it's available for free but not open source. As of 2013 we will not be funding any new versions. I'm not making any money out of it in any way. I just hope it gets put to more use.)

A third option I'm looking into now is to use an XSLT file along with the XSLT Transformation (Conversion) tool. I'm pretty much having to learn the language as I go though, and they don't make it easy on you by using the .NET implementation which uses the older XSLT/XPath 1.0 standards.

I have some code that uses ArcPy and DOM for conversion of existing MD, creation from scratch (if none exists) and update of certain elements using DOM. It's a bit clunky, with quite a lot of hardcoded pathnames and so on.

It's a kind offer, Steve, and much appreciated, but it's not consistent with this site's aims or structure. Please read our FAQ for more information. Unless the code is really long, you should be able to post it in a reply.
–
whuber♦Feb 15 '12 at 16:30

I realize this is quite a while after the question, but we just had a big need for a similar capability and ended up building a general, free, open source Python library for the purpose. You can find it at https://github.com/ucd-cws/arcpy_metadata or by running a "pip install metadata" - documentation is still to come, but we tried to keep things relatively Pythonic. Here's an example:

import arcpy_metadata as md
import datetime
metadata = md.MetadataEditor(path_to_some_feature_class) # also has a feature_layer parameter if you're working with one, but edits get saved back to the source feature class
metadata.title.set("The metadata title!")
generated_time = "This layer was generated on {0:s}".format(datetime.datetime.now().strftime("%m/%d/%Y %I:%M %p"))
metadata.purpose.set("Layer represents locations of the rare Snipe.")
metadata.abstract.append("generated by ___ software")
metadata.abstract.append(generated_time) # .prepend also exists
metadata.tags.add(["foo", "bar", "baz"]) # tags.extend is equivalent to maintain list semantics
metadata.finish() # save the metadata back to the original source feature class and cleanup. Without calling finish(), your edits are NOT saved!

It still has plenty that could be added, but is pretty extensible if you subclass the items that are already there, or configure them correctly. It's still about alpha quality software, but it works and we're happy with it. Feedback and contributions are certainly welcome.