Verify XML file syntax on a console using Python


Put the following code in a file, for example test.py:

#!/usr/bin/python
import xml.dom.minidom as dom
dom.parse ('test.xml')

And make it executable:

chmod 755 test.py

Execute

./test.py

If your xml file test.xml is correct, it should output nothing, else it outputs an error!

Of course this script may be improved, for example to take the xml file as parameter ..