使用PHP创建大型xml文件的最佳方法是什么?

I try to create a xml file with php.

As file is an extract of mySQL database, the recordset may contain around 90000 rows. So generate the xml file is slow, around 50s.

I don't want to make a dump, but only create a file to send to Flashbuilder to create a dataprovider.

I try to use several process:

DOMDocument
XmlWriter
SimpleXMLElement

But with those methods, time to create file is the same.

I made another test on server side, with this directive : ini_set('memory_limit','-1');

Do you know another approach, to write large xml file too speed.

Thanks for helping.

Are you sure you want to route your data through PHP? Maybe you can use the mysqldump ability to create the output in XML: See the MySQL docu on this.

mysqldump -X yourDb yourTable

mysqldump would be the best for this.

Else depends if you have a specific format for the files. The best way is probably just to iterate results and build the file "manually" with php. phpMyAdmin can also export xml. Something really simple would be ...

$rows = '<? xml... ?>';
$query = mysql_query(); 
while($row = mysql_fetch_assoc($query)){
  $rows .= "<row>
";
  foreach($row as $tag=>$val){
    $rows.= "<$tag>$val</$tag>
";
  }
  $rows .= "</row>
";
}

file_put_contents('sql.xml',$rows);

but you could very well be trying to do something that is just going to take time to process, and that php isn't the best tool for, i.e. mysqldump