Question

Let's say I want to be able to validate that a 50GB+ XML file conforms to a given XSD. I could use

DOMDocument::load & DOMDocument::schemaValidate

but that will take all of time on loading and will generally exhaust all available memory for me. Is there any way to feed an XSD to a SAX or any other type of stream processor and have it verify that all is well?

Was it helpful?

Solution

You may use XMLReader:

$reader = new XMLReader();
$reader->open('xmlfile.xml');
$reader->setSchema('schemafile.xsd');
while($reader->read());
$reader->close();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top