Validate an XML against XSD and send errors to a file?

Viewed 64

I need to validate an XML against an XSD, I am using xmllint:

xmllint --schema schema.xsd feed.xml --noout

But it seems that I cannot save the output of the validation to a file.

Using -o or --output or > to redirect the output to a file will output the parse XML, but how do I redirect the validation errors to file?

1 Answers

You can redirect stderr in general via 2>, so

xmllint --schema try.xsd try.xml --noout 2>errors.txt
                                         ^^^^^^^^^^^^

will redirect the errors to errors.txt.

Related