On his blog today Sameer has a quick new tutorial looking at using the XML_Beautifier PEAR package to "pretty up" your XML documents.
I use xmlPad to format and analyze xml documents, but many times I need to format xml documents on the production server wherein xmlPad is of no use. What one needs is a library that would allow you to beautify your untidy xml documents within your php code. XML_Beautifier provides that solution.
He walks you through the installation and use of the package on a sample script - pulling in the "ugly" XML and outputting the "pretty" XML via the package's formatFile function.