private/Get-SfMetadataXmlFile.ps1

function Get-SfMetadataXmlFile {
<#
    .SYNOPSIS
    Read a metadata xml file and return as XML object.
#>


    [CmdletBinding()]
    param (
        # Path to the XML file to be read.
        [Parameter(Mandatory, Position=0)]
        [string]$Path
    )

    Write-Debug "Path: [$Path]"

    $XmlReaderSettings = New-Object -TypeName System.Xml.XmlReaderSettings
    $XmlReaderSettings.IgnoreComments = $true

    $XmlReader = [system.Xml.XmlReader]::Create($Path, $XmlReaderSettings)

    try {
        $xml = New-Object -TypeName XML
        $xml.Load($XmlReader)
    }
    finally {
        $XmlReader.Dispose()
    }

    return $xml

}