Re: Reading from XML file

From: Date: Tue, 25 May 2004 14:35:07 +0000
Subject: Re: Reading from XML file
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-186892@lists.php.net to get a copy of this message
Ago wrote:
It is not a database problem, it seems to me something about the reading of the XML file. This is my code about this: You can't rule out the database because, inserts are a resource intensive task.
$data = implode(file("example.xml"), ""); ouch!!
xml_parse_into_struct($parser, $data, &$structure, &$index); you will be suckingup all the processor and memory with an operation like this. definitely not what you want to do with a web app. If you look at the sax parser examples in the php manual you will see how you can sequentially read in the data (and insert the data one at a time) instead of keeping the whole thing in memory.
xml_parser_free($parser); it could be the array $data creation fails because the example.xml is too big, There you are.
infact if I decrease the size of xml file the script works (even if it lasts several minutes), There you are. You might even find that event driven SAX parser example i just refered to is a lot faster.
unfortunately the xml_parse_into_struct function needs the $data array as argument. My PHP version is 4.0.6. -- Raditha Dissanayake. --------------------------------------------- http://www.raditha.com/megaupload/upload.php Sneak past the PHP file upload limits.


« previous php.general (#186892) next »