xmllintΒΆ

xmllint is a command line tool that is usually available on most *nix machines, including OS X (http://xmlsoft.org/xmllint.html). It is part of libxml2 and if its not already on your system you can download binaries for most platforms.

There are two main things that you might want to use xmllint for. Checking that a CellML document is valid XML and creating a nicely formatted version of the document. You can achieve both of these with the command:

$> xmllint --format <file.xml>

which will check that file.xml is a valid XML document and print a nicely formatted version of the document to the terminal if it is valid. If your document is quite large, you probably don’t want to print it to the terminal as it might obscure some useful warnings. In that case you should do something like:

$> xmllint --format <file.xml> > <new-file.xml>

which will do the same as above, but now if you have a valid XML document the formatted XML document will be in new-file.xml.