sortxml (week #22)
Tuesday, May 28, 2013
Labels:
Application of the Week 2013
,
Utility
It is simple to use.
USAGE: sortxml.exe [options] infile [outfile]
infile The name of the file to sort, etc.
outfile The name of the file to save the output to.
If this is omitted, then the output is written to stdout.
OPTIONS:
--pretty Ignores the input formatting and makes the output look nice.
--sort Sort both the nodes and attributes.
--sortnode Sort the nodes.
--sortattr Sort the attributes.
(prefix an option with ! to turn it off.)
The default is to output pretty and sorted nodes and attributes. So, given the following:
$ type sample.xml
<root><node attr="name" value="one"></node></root>
Would output the following: $ sortxml.exe sample.xml
<root>
<node attr="name" value="one">
</node>
</root>
I created this utility so I can use it as a File Format in Beyond Compare. Here is the gist of the File Format in BC3. Helpers\sortxml.exe --pretty --sortnode --!sortattr %s %t
Check out the source code at GitHub!