Created
September 19, 2012 09:55
-
-
Save veganista/3748789 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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