I have this problem in terms of processing time of a large xml files. By large, i mean 600MB on the average. Currently, It takes about 50 - 60 minutes to parse and insert the data into a database. I would like to ask for suggestions on how can I improve the processing time? Like goind down to 20 minutes.
Because with the current time it will take me 2.5 months to populate the database with the content from the xml. By the way I have 3000+ xml files with the average of 600mb. And my php script in command line thru cron job.
I have also read other questions like the one below, but I have not found any idea yet. What is the fastest XML parser in PHP?
I see that some have parsed files up to 2GB. I wonder how long are the processing time.
I hope you guys could lend your help. It would be much appreciated. Thanks.
I have this code:
$handler = $this;
$parser = xml_parser_create('UTF-8');
xml_set_object($parser, $handler);
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_set_element_handler($parser, "startElement", "endElement");
xml_set_character_data_handler($parser, "cdata");
$fp = fopen($xmlfile, 'r');
while (!feof($fp)) {
while (($data = fread($fp, 71680))){
}
}
I put first the parse data in a temporary array. My mysql insert commands are inside the endElement function. There is a specific closing tag to trigger my insert command to the database.
Thanks for the response....