Parsing huge XML Files in PHP
I'm currently working on a project which requires importing small and big XML files. When I got to stress testing I realised Simple XML was crunching at files over 100mb. I wasn't prepared to keep upping the PHP memory limit so I started to look at alternative methods.
I did some tests with DOMDocument and XMLReader and found baking my own Iterator with XMLReader was the best choice. I'm sure DOMDocument was loading the entire XML file into memory like SimpleXML.
So if you have a XML file which is a few hundred megs big use XMLReader and check out this link for an example of an Iterator.
Have a good weekend!
Friday, 13th February, 2009

Comments
There are no comments for this article.
Add A Comment