FeaturePhp/Helper/XmlParser.php
public function validate($schemaFile) {
        if (!$this->xmlString)
            throw new XmlParserException("attempting to validate before parsing");
            
        if (!extension_loaded("DOM")) {
            trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE);
            return $this;
        }

        libxml_use_internal_errors(true);
        $document = new \DOMDocument();
        $document->loadXML($this->xmlString);
        
        if (!$document->schemaValidate($schemaFile)) {
            $msg = "The following XML errors occurred while validating:";
            foreach (libxml_get_errors() as $error)
                $msg .= "\n" . $error->message;
            throw new XmlParserException($msg);
        }

        return $this;
    }
public function validate($schemaFile) {
        if (!$this->xmlString)
            throw new XmlParserException("attempting to validate before parsing");
            
        if (!extension_loaded("DOM")) {
            trigger_error("DOM extension not loaded, will not validate XML", E_USER_NOTICE);
            return $this;
        }

        libxml_use_internal_errors(true);
        $document = new \DOMDocument();
        $document->loadXML($this->xmlString);
        
        if (!$document->schemaValidate($schemaFile)) {
            $msg = "The following XML errors occurred while validating:";
            foreach (libxml_get_errors() as $error)
                $msg .= "\n" . $error->message;
            throw new XmlParserException($msg);
        }

        return $this;
    }
public function validate ( $ schemaFile ) { if ( ! $ this -> xmlString ) throw new XmlParserException ( "attempting to validate before parsing" ) ; if ( ! extension_loaded ( "DOM" ) ) { trigger_error ( "DOM extension not loaded, will not validate XML" , E_USER_NOTICE ) ; return $ this ; } libxml_use_internal_errors ( true ) ; $ document = new \ DOMDocument ( ) ; $ document -> loadXML ( $ this -> xmlString ) ; if ( ! $ document -> schemaValidate ( $ schemaFile ) ) { $ msg = "The following XML errors occurred while validating:" ; foreach ( libxml_get_errors ( ) as $ error ) $ msg .= "\n" . $ error -> message ; throw new XmlParserException ( $ msg ) ; } return $ this ; }
Validates XML using a schema.
@param string $schemaFile
@return XmlParser
Validates XML using a schema .