FYI: Your post appears to have some missing information.
No worries. I'm just trying to get enough information so that I can create a prototype solution for you. Give me a few minutes to try a few things.
Try something like this:
function Read-XmlFile { [CmdletBinding()] param( [Parameter(Mandatory = $true)] [ValidateScript({Test-Path -Path $_})] [string] $Path ) $doc = New-Object -TypeName System.Xml.XmlDocument $doc.set_PreserveWhitespace($true) $doc.Load($Path) $doc.SelectNodes('//logged') | ForEach-Object -Process { $parent = $_.get_ParentNode() $null = $parent.RemoveChild($_) } $doc.get_OuterXml() -split [System.Environment]::NewLine } $refFile = 'C:\temp\file1.xml' $difFile = 'C:\temp\file2.xml' $refDoc = Read-XmlFile -Path $refFile $difDoc = Read-XmlFile -Path $difFile Compare-Object -ReferenceObject $refDoc -DifferenceObject $difDoc
Be aware that Compare-Object will only give you line by line differences rather than perform a proper XML diff that follows XML rules (like ignoring whitespace, etc.).