I have some code that exports metadata from an iMetadata instance to a standalone XML file. This code uses the ExportXML type and the iMetadataExport interface (see below).
Private Sub ExportMetadatatoXML(ByVal Metadata As IMetadata, ByVal strXMLdocName As String, ByVal strOutputXmlFolder As String) Try Dim ExportXML As ExportXML Dim xml_Export As IMetadataExport ExportXML = New ExportXML xml_Export = ExportXML If System.IO.Directory.Exists(strOutputXmlFolder) Then xml_Export.Export(Metadata, strOutputXmlFolder & "\" & strXMLdocName & ".xml") Logging.WriteToLog("Metadata Exported to " & strOutputXmlFolder & "\" & strXMLdocName & ".xml", Serverity.SeverityLevel.Information) Else Logging.WriteToLog("Output XML Directory " & strOutputXmlFolder & " cannot be found", Serverity.SeverityLevel.Fatal) Result = Result - 1 End If Logging.WriteToLog("Metadata was not exported to " & strOutputXmlFolder & "\" & strXMLdocName & ".xml", Serverity.SeverityLevel.Information) Catch ex As Exception Dim strRoutine As String = "Error thrown in: " & System.Reflection.MethodBase.GetCurrentMethod.Name Logging.WriteToLog(strRoutine & " - " & ex.Message, Serverity.SeverityLevel.Fatal) Result = Result - 1 End Try End Sub
This code worked a treat for 9.x versions of ArcGIS, but with the new metadata changes for 10+, it no longer works. The ExportXML type seems to no longer exist and I can't seem to figure out a replacement. Does anyone know how I can achieve this with 10+? I've noticed there's a metadata toolbox but would rather avoid using geoprocessing. Thanks for your time.
Edit: I have since tried using geoprocessor to export to XML, but i'm getting a hresult error on gp.execute. Can anyone suggest what the problem might be?
Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor Dim parameters As IVariantArray = New VarArray parameters.Add("C:\Temp\Temp.gdb\BLOCKS") parameters.Add("C:\Program Files\ArcGIS\Desktop10.1\Metadata\Translator\ARCGIS2FGDC.xml") parameters.Add("C:\Temp\Metadata\blocks.xml") GP.Execute("ExportMetadata_conversion", parameters, Nothing)