A nifty tool when dealing with misfit XML documents is XML Pretty Printer. This command line tool will do exactly as it says: print pretty XML. Example usage:
xml_pp foo.xml > foo_pp.xml
In order to install xml_pp, you’ll need to use your package manager. For example, in Fedora you use
yum install perl-XML-Twig and in Debian/Ubuntu you use
apt-get install xml-twig-tools.
As always, be sure to check out the man page for xml_pp.