note 80564 modified in function.xmlreader-isvalid by danbrown

From: Date: Fri, 28 Nov 2008 21:40:29 +0000
Subject: note 80564 modified in function.xmlreader-isvalid by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147254@lists.php.net to get a copy of this message
This comment is only partially correct: "isValid() always returns false unless you enable checking for validity by $reader->setParserProperty(XMLReader::VALIDATE, true);" This enables DTD checking, but you can also check by using RelaxNG (see setRelaxNGSchema() and setRelaxNGSchemaSource()). And also, this is NOT correct: "If you just need to check if XML file is well formed, successful loading into XMLReader object is usually enough." It is not enough. Pull parsers operate on stream and if you have a large enough file they will not know it is well formed until it is read to the end. If you need to know if it is well formed or/and valid, read it till the end or validation error (you can use next() for fast reading if you don't care about contents). --was-- This comment is only partially correct: "isValid() always returns false unless you enable checking for validity by $reader->setParserProperty(XMLReader::VALIDATE, true);" This enables DTD checking, but you can also check by using RelaxNG (see setRelaxNGSchema() and setRelaxNGSchemaSource()). And also, this is NOT correct: "If you just need to check if XML file is well formed, successful loading into XMLReader object is usually enough." It is not enough. Pull parsers operate on stream and if you have a large enough file they will not know it is well formed until it is read to the end. If you need to know if it is well formed or/and valid, read it till the end or validation error (you can use next() for fast reading if you don't care about contents). http://php.net/manual/en/function.xmlreader-isvalid.php

« previous php.notes (#147254) next »