9951 explained code solutions for 126 technologies


pythonHow to validate xml


import xmlschema

try:
  xmlschema.validate('file.xml', 'schema.xsd')
  print('XML is valid')
except:
  print('XML is invalid')ctrl + c
xmlschema

XML validator module, more info

xmlschema.validate(

validate given XML file with given XML schema

file.xml

XML file to validate

schema.xsd

Schema to use for validation