首页 > 语言 > PHP > 正文

php操作xml并将其插入数据库的实现方法

2024-05-04 23:49:37
字体:
来源:转载
供稿:网友

如下所示:

<?phpheader('content-type:text/html;charset=utf-8');mysql_connect('localhost', 'root', '');mysql_select_db('test');mysql_query('SET names utf8');$xml_array=simplexml_load_file('suggest.xml'); //将XML中的数据,读取到数组对象中foreach($xml_array as $tmp){	$sql = "insert into `countries` (`id` ,`value`) VALUES (NULL , '".$tmp->field."')";	mysql_query($sql);echo $tmp->field."<br>";}?> 

以上这篇php操作xml并将其插入数据库的实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持VeVb武林网。


注:相关教程知识阅读请移步到PHP教程频道。
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选