ArcGIS Pro 3.1 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / Map Class / SetMetadata Method
The xml formatted metadata
Example

In This Topic
    SetMetadata Method (Map)
    In This Topic
    Sets the Map metadata. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    public void SetMetadata( 
       string metadataXml
    )
    Public Sub SetMetadata( _
       ByVal metadataXml As String _
    ) 

    Parameters

    metadataXml
    The xml formatted metadata
    Exceptions
    ExceptionDescription
    This method or property must be called within the lambda passed to QueuedTask.Run.
    There is a load or parse error in the XML
    Remarks
    The input xml must be a valid metadata document and, as a minimum, have a root <metadata> element. The Map metadata must be editable. Refer to GetCanEditMetadata.
    Example
    Get and Set Map Metadata
    var map = MapView.Active.Map;
    if (map == null) return;
    //Get map's metadata
    var mapMetadata = map.GetMetadata();
    //TODO:Make edits to metadata using the retrieved mapMetadata string.
    
    //Set the modified metadata back to the map.
    if (map.GetCanEditMetadata())
      map.SetMetadata(mapMetadata);
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.0 or higher.
    See Also