from lxml import etree xml_file = 'teste.mmp' xsd_file = 'mmp.xsd' with open(xsd_file, 'rb') as f: schema_doc = etree.XML(f.read()) schema = etree.XMLSchema(schema_doc) with open(xml_file, 'rb') as f: doc = etree.XML(f.read()) if schema.validate(doc): print("XML válido!") else: print("XML inválido!") print(schema.error_log)