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)

        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)
            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:\Program Files\ArcGIS\Desktop10.1\Metadata\Translator\ARCGIS2FGDC.xml")
        GP.Execute("ExportMetadata_conversion", parameters, Nothing)

1 Answer 1


This page states that the ExportXML coClass was removed in version 10.0 so this is why your code has stopped working.

If you want your code to be as simple as your original code then by far the easiest method is to call the export geoprocessing tool using the IGeoProcessor.

Otherwise you would need to obtain the propertyset and write out each element of the XML which would be a lot of work.

Here is an example of how I would do it in VBA:

Public Sub test()
    Dim pGP As IGeoProcessor2
    Set pGP = New GeoProcessor
    Dim pVarArray As IVariantArray
    Set pVarArray = New VarArray
    With pVarArray
        .Add "C:\temp\landuse_.shp"
        .Add "C:\Program Files\ArcGIS\Desktop10.2\Metadata\Translator\ARCGIS2FGDC.xml"
        .Add "C:\temp\x.xml"
    End With
    Dim pRes As IGeoProcessorResult2
    Set pRes = pGP.Execute("ExportMetadata_conversion", pVarArray, Nothing)
End Sub
  • Thanks for the reply. It seems odd that there isn't a simple solution available anymore without resorting to geoprocessing tools. Anyway, I've attempted exporting using geoprocessor but I have a new problem. Any idea what I'm doing wrong? I've edited my original question with the code.
    – pvdev
    Commented Feb 3, 2014 at 15:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.