def validate_xml(xsd_filename, xml_filename):
 with open(xsd_filename, 'r') as f:
  schema_root = etree.XML(f.read())
 schema = etree.XMLSchema(schema_root)
 xmlparser = etree.XMLParser(schema=schema)
 with open(xml_filename, 'r') as f:
  etree.fromstring(f.read(), xmlparser)

def validate_xml ( xsd_filename , xml_filename ) : with open ( xsd_filename , 'r' ) as f : schema_root = etree . XML ( f . read ( ) ) schema = etree . XMLSchema ( schema_root ) xmlparser = etree . XMLParser ( schema = schema ) with open ( xml_filename , 'r' ) as f : etree . fromstring ( f . read ( ) , xmlparser )
validate a generated xml file against the xsd .