开发者_StackOverflow中文版Is there a way to convert an xml file to a mysql table as a sql statement using php?
I'm open to any PEAR packages you know of.
Actually, parsing XML to MySQL is a direct task and need a lot customization based on your XML structure. I suggest you to use SimpleXML to parse XML and insert into MySQL using PHP's MySQLi classes.
there are several packages available to read XML data in PHP (parsing XML). You can write simple code to insert the same in mysql with your custom fields.
I used ParseXml.class.php from phpclasses.org
The code should use like below.
require './ParseXml.class.php';
$xml = new ParseXml();
$xml->LoadFile("./test.xml");
//$xml->LoadString($xmlString);
//$xml->LoadRemote("http"//www.yourdomain.com/dir/filename.xml", 3);
$dataArray = $xml->ToArray();
精彩评论