Problem validating XML
Posted: Tue Jan 13, 2015 12:20 pm
Code: Select all
$xml = new DOMDocument ();
$xml->load ( $xmlFilePatht );
if (! $xml->schemaValidate ( $xmlSchema )) {
echo basename($xmlFilePath) . " is invalid according to " . basename($xmlSchema) . " the errors are:" . PHP_EOL;
$errors = libxml_get_errors ();
foreach ( $errors as $error ) {
print libxml_display_error ( $error );
}
Code: Select all
<?xml version="1.0"?>
<example>
<child_string>This is an example.</child_string>
<child_integer>Error condition.</child_integer>
</example>