Question: > 
> **Possible Duplicate:**  
> 
> [Parsing Huge XML Files in PHP](https://stackoverflow.com/questions/911663/parsing-huge-xml-files-in-php) 
> 
> 
> 

I am trying to parse a 70Mb XML file under PHP. After a while the resources are not enough and the script crashes. If there is a larger XML file it ends sooner. I can't change the memory limit of the server and of PHP. 

What can I do to parse large files? The file size can vary, and it's not always 70Mb, it could easily be 200Mb.

Answer: 
You can use the [XMLReader](http://docs.php.net/xmlreader) class.  

It doesn't read the entire document as an object model into the memory but is a [pull parser](http://en.wikipedia.org/wiki/XML#Pull_parsing).
In general, when you want to parse large XML documents in a constrained environment, you should use a SAX parser, that does not store the entire document in any form. SAX parsers make calls to user defined functions when they encounter an opening or closing tag for example.