ArcGIS Pro 2.7 API Reference Guide
SetXml Method (IMetadata)
Example 

ArcGIS.Desktop.Core Namespace > IMetadata Interface : SetXml Method
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
await QueuedTask.Run(() =>
{
  var xml = System.IO.File.ReadAllText(@"E:\Data\Metadata\MetadataForFeatClass.xml");
  //Will throw InvalidOperationException if the metadata cannot be changed
  //so check "CanEdit" first
  if (featureClassMetadataItem.CanEdit())
    featureClassMetadataItem.SetXml(xml);
});
     
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

IMetadata Interface
IMetadata Members