how to Validate a XML file with XSD through xmllint

Econ picture Econ · Mar 15, 2017 · Viewed 42.9k times · Source

i have to validate my xml file with a given XSD file. Figured the easiest way to do so would be xmllint, but i can't get it to work. Can anyone tell me the exact command?

I tried:

     xmllint --valid myxsd.xsd myxml.xml

What am i doing wrong? This only outputs the 2 files in the command line

edit: have to do it in console, because it will be needed in a build process

Answer

Econ picture Econ · Mar 15, 2017

Figured it out, had to use --schema instead of --validate.

xmllint --schema yourxsd.xsd yourxml.xml --noout

The --noout makes sure your code in XSD and XML doesn't show. With this option you will only see the Validation Errors.