2006/10/01

HOWTO: Format nicely an XML document (beautifying XML)

From time to time I have an XML file that needs to be formatted nicely. If the file is small, I usually do it manually.

However, lately I was working with SSIS. I created a package with an XML configuration file. And it came out that Visual Studio 'thinks' it is a great idea to put all content of the file in one line. Well, it is not, but I have already got used to such bugs in SQL Server 2005.

The configuration file was totally unreadable, but I remembered that I had already had such problem in the past. After some searching, I downloaded XMLStarlet (that I had also used last time).

All you have to do to format nicely an XML file is to type:

xml.exe format ugly_formatted.xml > nicely_formatted.xml

Of course, XMLStarlet can do much more.

No comments:

Post a Comment