root = etree.XML('<foo/>')
print(dtd.validate(root))
root = etree.XML('<foo>bar</foo>')
print(dtd.validate(root))
print(dtd.error_log.filter_from_errors())
How do I validate xml against a DTD file in Python