I have two files:
- Sample XML file.
- The .xsd w / schema file to which the specified XML file should follow.
To check the XML file for the schema, I used:
$dom = new DOMDocument();
$dom->loadXML($this->xmlstr);
if(!$dom->schemaValidate($xsd_file)){
$errors = libxml_get_errors();
var_dump($errors);
}
However, I keep getting warnings when my XML document does not adhere to the rules in the schema.
Warning: DOMDocument :: schemaValidate () [domdocument.schemavalidate]: Title element: this element is not expected. Expected (Routing)
I intentionally twisted my XML file, just to find out how it really handles $ dom-> schemaValidate. Obviously, I do not want PHP to display warning messages on the page whenever XML does not match the schema. Instead, I want my application to take care of this. Did I forget something?