Reputation: 5243
I have a xml
file that has more than 5000 products (items). It's really a big file and the execution of parsing that file is taking more than 40 seconds.
My php code :
ini_set('max_execution_time', 300);
$xml = simplexml_load_file("wwww.example.com");
print_r($xml);
Is there any solution for this?? for example loading just a part of file?
Upvotes: 2
Views: 678
Reputation: 117333
XMLReader is another solution, like SAX (or expat), that allows you to read the XML file incrementally and it should be easier to work with than the former.
It can make things substantially faster if you don't need to parse the whole file and can stop when you've found what you were looking for.
If you still need to parse the whole file with it, it won't offer a speedup.
Upvotes: 1
Reputation: 11
Try to call the simplexml_load_file
function with LIBXML_COMPACT
flag:
$xml = simplexml_load_file("wwww.example.com",'SimpleXMLElement',LIBXML_COMPACT);
Upvotes: 1