Created
January 20, 2015 13:28
-
-
Save pbertera/57d2b8721d8ef9cd67bb to your computer and use it in GitHub Desktop.
Usage: pyxmlvalidator.py file1.xml file2.xml ...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from xml.sax.handler import ContentHandler | |
from xml.sax import make_parser | |
from glob import glob | |
import sys | |
def parsefile(file): | |
parser = make_parser() | |
parser.setContentHandler(ContentHandler()) | |
parser.parse(file) | |
for arg in sys.argv[1:]: | |
for filename in glob(arg): | |
try: | |
parsefile(filename) | |
print "%s is well-formed" % filename | |
except Exception, e: | |
print "%s is NOT well-formed! %s" % (filename, e) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment