HI
I have to create a huge XML file from a millions records table using php as per some xsd.
When I create 60000 records XML file it gets the size of 2Gb. WIth 2 milion record the XML file is going to be huge but I want to create a single XML file.
I know that dom document won’t work at all. So, I also tried XMLwriter but it also gives me an error as “out of memory” excatly after 2GB creation of XML file. I do not know if XMLWriter has any creteria of memory but if it has what is the other option of creating huge file which are more than 2GB.
My code snippets looks like
[php]$i =0;
//some query sql statment which return result in $result
$writer->startElement(‘persons’);
while($row = mysql_fetch_row($result))
{
$writer->startElement(‘person’);
$writer->writeElement(‘UniqueIdentifier’,$row[0]);
$writer->writeElement(‘Name’,$row[1]);
$writer->startElement('geos');
$writer->writeElement('Latitude',$row[4]);
$writer->writeElement('Longitude',$row[5]);
$writer->endElement();
$writer->endElement();
if($i == 1000)
{
file_put_contents('new_Xml_CTFS_row.xml', $writer->flush(true), FILE_APPEND);
$i = 0;
}
}
$writer->endElement();
file_put_contents(‘new_Xml_CTFS_row.xml’, $writer->flush(true), FILE_APPEND);[/php]
Please let me know what is the other option to do this or how can I create huge XML files more than 2GB in php
It will be great if I can get the answer fast. Its kind of urgent
Thanks,
s