Jump to content

Problem parsing large XML File


aswebdesign

Recommended Posts

Hi all,

 

I have been trying to parse a 250MB xml file using PHP5's XMLReader.

 

This is working perfectly for small files but stops mid process (without any error messages) after about 10 seconds when processing test xml files around 16MB.

 

Has anyone got any suggestions??

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/51849-problem-parsing-large-xml-file/
Share on other sites

You are most likely exceeding php's assigned memory limit. 

 

You have a couple of choices...increase the memory limit in php.ini, which isn't recommended...especially not for a 250 MB file cause each time your script is called it would load all 250mb into memory...imagine having 1000 concurrent visitors, each using 250 MB of memory.

 

The other choice would be to split the file up.  You may be able to use fread to read the file in and process it in smaller pieces, but I'm not sure since it's XML, which may be finicky.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.