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

ArcGIS.Desktop.Core Namespace > IMetadata Interface : GetXml Method
Gets the item’s metadata XML document as a string.
Syntax
string GetXml()
Function GetXml() As String

Return Value

Metadata xml string
Remarks
Not all items support metadata. Be sure to check for empty string or null as the return value from GetXml.
Example
string gdbXMLMetadataXmlAsString = string.Empty;
gdbXMLMetadataXmlAsString = await QueuedTask.Run(() => gdbMetadataItem.GetXml());
//check metadata was returned
if (!string.IsNullOrEmpty(gdbXMLMetadataXmlAsString))
{
  //use the metadata
}
Requirements

Target Platforms: Windows 10, Windows 8.1

See Also

Reference

IMetadata Interface
IMetadata Members