Friday, October 9, 2009

XML Pretty Formatting

I've had this problem for a long time. A huge XML document which is not formatted. Finally found the simplest solution... HTML Tidy library. Grab the EXE from SourceForge: http://tidy.sourceforge.net/. Then run the following command:
tidy -xml -indent -quiet -o "output.xml" input.xml
This will read the input.xml file and treat it as a well formed XML. No additional output will be displayed on screen. Output file will be written to output.xml.

This thing is *fast*. It parsed an 8MB XML file within seconds.

Man... Don't know why I didn't figure this out earlier... Sheshh...

No comments: