Sie können das XML-Parsing in Powershell nativ nutzen! Auf diese Weise können Sie einfach den Inhalt des XML-Elements lesen, anstatt zu versuchen, alles auszudrücken.
$path = "E:\files" $outfile = "E:\testoutput.txt" $files = Get-Childitem $path *.xml -Recurse | Where-Object { !($_.psiscontainer) } $elem = "Tag" #<- The name of the XML element to find # Loop through all the $files foreach ($file in $files) { $file.Name | Out-File $outfile -Append $doc = [xml](Get-Content $file.FullName) # <- Read in content as XML # Loop through each element named by $elem $doc.GetElementsByTagName($elem) | ForEach-Object { $_ | Out-File $outfile -Append } }