我想将XML数据插入数据库,但是没有插入某些字段 我有像这样的XML数据
SimpleXMLElement Object (
[person-id] => 4562
[name] => gopi
[category] => working
[lead-commission] => SimpleXMLElement Object ( )
[expire-date] => SimpleXMLElement Object ( )
[manufactur-date] => SimpleXMLElement Object ( )
[type] => medicine [sale-commission] => 1.00%
)
我要插入数据库的代码
foreach($xml->link AS $value)
{
$data['person-id']= $value->{'person-id'};
$data['name']= $value->{'name'};
$data['category']= $value->{'category'};
$data['lead-commission']= $value->{'lead-commission'};
$data['expire-date']= $value->{'expire-date'};
$data['manufacture-date']= $value->{'manufactur-date'};
$data['type']= $value->{'type'};
$data['sale-commission']= $value->{'sale-commission'};
}
但我无法在我的数据库中插入主管佣金,过期日期,制造日期,请您帮忙我如何插入这个字段
答案 0 :(得分:-1)
您可以使用此功能并将XML转换为PHP数组
http://www.lalit.org/lab/convert-xml-to-array-in-php-xml2array/
然后使用“print_r()
”查看字段和数组结构。因此插入数据。
希望提供的链接有帮助