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

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

    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. The MapMember metadata must be editable. Refer to GetCanEditMetadata.
    Example
    Layer Metadata
    {
        //Search for only layers/tables here if needed.
        MapMember mapMember = map.GetLayersAsFlattenedList().FirstOrDefault();
        if (mapMember == null) return;
        //Note: Run within a QueuedTask
        //Gets whether or not the MapMember stores its own metadata or uses metadata retrieved
        //from its source. This method must be called on the MCT. Use QueuedTask.Run
        bool doesUseSourceMetadata = mapMember.GetUseSourceMetadata();
    
        //Sets whether or not the MapMember will use its own metadata or the metadata from
        //its underlying source (if it has one). This method must be called on the MCT.
        //Use QueuedTask.Run
        mapMember.SetUseSourceMetadata(true);
    
        //Does the MapMember supports metadata
        var supportsMetadata = mapMember.SupportsMetadata;
    
        //Get MapMember metadata
        var metadatstring = mapMember.GetMetadata();
        //TODO:Make edits to metadata using the retrieved mapMetadata string.
    
        //Set the modified metadata back to the mapmember (layer, table..)
        if (mapMember.GetCanEditMetadata())
            mapMember.SetMetadata(metadatstring);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also