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).
XMLReader->isValid
(No version information available, might be only in CVS)
XMLReader->isValid — Zeigt an, ob das geparste Dokument valide ist
Beschreibung
XMLReader
bool isValid
( void
)
Gibt einen boolschen Wert zurück, der anzeigt, ob das geparste Dokument sich aktuell in einem validen Zustand befindet.
Rückgabewerte
Gibt bei Erfolg TRUE zurück, im Fehlerfall FALSE.
XMLReader->isValid
anzenews at volja dot net
22-Jan-2008 10:50
22-Jan-2008 10:50
patryk dot szczyglowski at gmail dot com
21-Dec-2007 06:10
21-Dec-2007 06:10
isValid() always returns false unless you enable checking for validity by:
$reader->setParserProperty(XMLReader::VALIDATE, true);
where $reader is XMLReader object.
Beware, once you enable this check, PHP will search for DTD file and possibly produce warnings.
If you just need to check if XML file is well formed, successful loading into XMLReader object is usually enough.
