ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Core Namespace / IMetadata Interface / SetXml Method
Example

In This Topic
    SetXml Method (IMetadata)
    In This Topic
    Sets the item’s metadata to the XML document provided as a string.
    Syntax
    void SetXml( 
       string xml
    )
    Sub SetXml( _
       ByVal xml As String _
    ) 

    Parameters

    xml

    Return Value

    void
    Remarks
    Existing metadata is replaced. Metadata is created for the item if it doesn't already exist.
    Example
    Item: Set the metadata of an item: SetXML
    {
      var xmlMetadata = File.ReadAllText(@"E:\Data\Metadata\MetadataForFeatClass.xml");
      await QueuedTask.Run(() =>
      {
        //Will throw InvalidOperationException if the metadata cannot be changed
        //so check "CanEdit" first
        if (featureClassMetadataItem.CanEdit())
        {
          featureClassMetadataItem.SetXml(xmlMetadata);
        }
      });
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also