How to detect and remove empty XML tags?
问题 I've got a bunch of XML files, I wish to detect and remove empty tags inside them. like: <My></My> <Your/> <sometags> <his> </his> <hasContent>sdfaf</hasContent> </sometags> They're all kinds of empty tags ( My , Your , his ) I wish to remove. Does PowerShell support such kind of empty tag detection, no matter how deep they're embedded inside other tags? 回答1: function Format-XML { param ( [parameter(Mandatory = $true)][xml] $xml, [parameter(Mandatory = $false)][int] $indent = 4 ) try { $Error