我有一個很大的XML文件,其中有22000條記錄,我必須在我的數據庫中導入。php large xml使用分頁解析
我期待如何解析分頁的XML,這意味着
parse.php?start=0; //this script get the 0-500 firt records of file
parse.php?start=500 //this script get the 500-1000 records of file
這樣我可以繞過內存問題。
我的問題是如何在創紀錄的500點時加載XML文件
我的代碼很簡單
$data=simplexml_load_file($xmlFile);
foreach ($data->product as $product) {
foreach($product->children() as $section) {
addToDB($section);
}
}
上面的代碼工作正常,1000-2000的記錄,但我想提到修改使用大型XML
這可能與此問題有關:http://bugs.php.net/bug.php?id=38604 – halfdan 2010-09-13 10:40:20