aswebdesign Posted May 17, 2007 Share Posted May 17, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/51849-problem-parsing-large-xml-file/ Share on other sites More sharing options...
hitman6003 Posted May 17, 2007 Share Posted May 17, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/51849-problem-parsing-large-xml-file/#findComment-255622 Share on other sites More sharing options...
effigy Posted May 17, 2007 Share Posted May 17, 2007 I'm assuming you're using DOM. If you do not need its capabilities, SAX should be more efficient. Quote Link to comment https://forums.phpfreaks.com/topic/51849-problem-parsing-large-xml-file/#findComment-255633 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.