# Desc: CMDLET to pretty print XML.
" Formats the XML into a nicely indented form (ie pretty printed)."
" Outputs one <string> object for each XML file."
" Specifies path to one or more XML files to format with indentation."
" Pipeline input is bound to this parameter."
" gci *.xml | Format-Xml"
throw "Pipeline input type must be one of: [xml], [string] or [IO.FileInfo]"
Ah, now that looks a lot more "elegant" compared to the one I tried.
It is a bit long. I think this would make a great little cmdlet and in fact I have implemented this as a cmdlet in the PowerShell Community Extensions projet (see the related blog posts).
Marc, I\’m guessing you copied the function above to a file and then tried to execute the function. You need to dot-source the file and then you can execute the function e.g.
Though it format the xml as “utf-16”, which is the default string encoding in .NET.