With XMLReader, you can achieve this. This avoids a large amount of RAM.
$xmlr = new XMLReader(); $xmlr->open('path/to/file'); // ... // move the pointer with $xmlr->read(), $xmlr->next(), etc. to the required // elements and read them with simplexml_load_string($xmlr->readOuterXML()), etc. // ... $xmlr->close();
source share