Ejemplo n.º 1
0
 /**
  * Check if the XML respect the DTD.
  * Require the XML_DTD package
  *
  * @param string $xml   The XML text to check
  *
  * @return boolean      Return true if valid
  * @access public
  */
 function isValid(&$xml)
 {
     $validator = new XML_DTD_XmlValidator();
     $tree = new XML_Tree();
     $nodes = $tree->getTreeFromString($xml);
     if (PEAR::isError($nodes)) {
         return $nodes;
     }
     $parser =& new XML_DTD_Parser();
     $validator->dtd = $parser->parse($this->_dtd);
     $validator->_runTree($nodes);
     if ($validator->_errors) {
         $errors = $validator->getMessage();
         return PEAR::raiseError($errors, XML_FASTCREATE_ERROR_DTD);
     }
     return true;
 }