将XML提要提取到PHP以插入MYSQL数据库

时间:2017-01-20 15:49:59

标签: php mysql

如果我尝试将所有内容插入数据库,一切正常,只有不起作用的内容是:编码因为它有:编码我想在我现有的字段中正确插入所有数据。 XML数据是新闻文章,我需要插入新数据库。

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.azned.nl/feed.xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

$indexFeed = simplexml_load_string($response);   
$indexFeed = str_replace("<content:encoded>","<contentEncoded>", $response);
$indexFeed = str_replace("</content:encoded>","</contentEncoded>", $response);
foreach($x->channel->item as $entry) {

$obj = $modx->newObject('modResource', array(
'pagetitle'             => $entry->pagetitle,
'description'           => $entry->description,
'content'               => $entry->contentEncoded,
'type'                  => 'document',
'longtitle'             => $entry->longtitle,
'link'                  => $entry->link,
'published'             => 1,
'pub_date'              => 0,
'alias'                 => $entry->pagetitle, $entry->longtitle,
'parent'                => 2,
'folder'                => 0,
'richtext'              => 1,
'template'              => 2,
'menuindex'             => 3,
'searchable'            => 1,
'cacheable'             => 1,
'createdby'             => 6,
'editedon'              => 6,
'editedby'              => 6,
'deleted'               => 0,
'deletedon'             => 0,
'deletedby'             => 0,
'publishedby'           => 6,
'donthit'               => 0,
'privateweb'            => 0,
'privatemgr'            => 0,
'content_dispo'         => 0,
'hidemnu'               => 0,
'class_key'             => 'Article',
'context_key'           => 'web',
'content_type'          => 1,
'uri_override'          => 1,
'hide_children_in_tree' => 0,
'show_in_tree'          => 0,
'properties'            => 'Properties'
));

0 个答案:

没有答案