Skip to content

XML File Validation

I wanted a quick-and-easy way to validate all the XML documents in one of my java projects. I found xmllint which is a great program. But I needed it to do a little more. Fortunately, its easy to wrap it in a shell script and make it do exactly what I want.

#! /bin/bash
# Chris Freyer
# Sept 10, 2009

for f in `find . -name "*.xml"`; do
        xmllint --nowarning --noout --valid $f
        rc=$?
        if [ $rc -gt 0 ]; then
                echo RC on $f was $rc
        fi
done