开发者

Convert xml to mysql using php?

开发者 https://www.devze.com 2023-03-20 00:08 出处:网络
开发者_StackOverflow中文版Is there a way to convert an xml file to a mysql table as a sql statement using php?

开发者_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();
0

精彩评论

暂无评论...
验证码 换一张
取 消