Monday, March 2, 2015

How to validate an xml against a dtd

xmllint is a command line XML tool, you can find this out of the box on must linux distributions.

In Windows you can use cygwin to install it.

Just install it as follows:

setup-x86_64 -qP libxml2
once is installed on your cygwin

Just call it as follows:

 xmllint --noout --dtdvalid orders.dtd order.xml

Where:

--noout will not print the xml as output.
--dtdvalid will check if an xml is valid against a particular .dtd.
The first file is your .dtd definition
and the Secnond file is the file that will be validated.


The output that you will get if the validation fails is as follows:



Post a Comment