PHP and Relax-NG validation

To validate an xml file with a Relax-NG schema in PHP, you can use the XMLReader library:

$xml_reader = new XMLReader();
if (!$xml_reader->isValid()) throw new Exception('failed RelaxNG validation);

I did not find how to retrieve corresponding error.
If you need a more verbose relax-ng validator, you can use ‘xmllint‘ in linux command console (part of ‘libxml2’ package).


Post a Comment

Your email is never published nor shared. You're allow to say what you want...