Skip to content

Instantly share code, notes, and snippets.

@veganista
Created September 19, 2012 09:55
Show Gist options
  • Save veganista/3748789 to your computer and use it in GitHub Desktop.
Save veganista/3748789 to your computer and use it in GitHub Desktop.
//set error handling up
libxml_use_internal_errors(true);
//path to the validation file
$validationSchema = dirname(__FILE__).DS.'docs'.DS.'tff'.DS.'XMLImport.xsd';
//set up a new document to work with
$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->preserveWhiteSpace = false;
//load the xml into doc
$doc->loadXML($xml);
//check the validation schema
if($doc->schemaValidateSource(DOMDocument::load($validationSchema)->saveXml()){
//validates so send...
}else{
//throw an exception with an error message built from validition errors if possible
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment