Reputation: 4337
I need to parse a huge XML that contains lots of job entries, like this
<?xml version="1.0" encoding="ISO-8859-1"?>
<items>
<item>
<title><![CDATA[...]]></title>
<description><![CDATA[...]]></description>
<link><![CDATA[...]]></link>
<city><![CDATA[...]]></city>
<state><![CDATA[...]]></state>
<position><![CDATA[...]]></position>
<company><![CDATA[...]]></company>
<category_id><![CDATA[...]]></category_id>
<job_id>...</job_id>
<salary><![CDATA[...]]></salary>
<term><![CDATA[...]]></term>
</item>
....
</items>
The server has enough memory to fully read that file but when if comes to parsing, it fails with "memory exhausted" error. Does PHP provide ways that would allow to split that file nicely or parse it in parts or anything that can be of help here. Thanks for any ideas and suggestions!
Upvotes: 0
Views: 435
Reputation: 307
Have you tried ramping up the memory?
ini_set("memory_limit", "128M")
place this code at the top of your php file. you can set the memory as high as you want
Upvotes: 1
Reputation: 31834
http://www.php.net/xmlreader can process it without using a ton of memory.
Upvotes: 1