我試着從<content:encoded>
得到的圖像網址和插入鏈接到我的DB獲得圖片src <內容:編碼>
,但我似乎無法從XML獲得正確的信息文件 -
還是不可能用simpleXML檢索數據?
這是我的XML
<item>
<title>Movietitle</title>
<content:encoded><![CDATA[<p>
<img class="aligncenter wp-image-22085" src="movie-poster-694x1024.jpg" alt="Predestination 2014" width="475" height="701" /></p>
<p><span id="more-22087"></span></p>
<p>
<a href="http://bit.ly/1za5mIz" target="_blank">
<h4 style="text-align: left;">Release Info:</h4>
Genre: Sci-Fi, Thriller<br />
Quality: DVDRip<br />
Language: English</p>]]>
</content:encoded>
</item>
PHP
$feeds = array('http://xxxx.xml');
foreach($feeds as $feed) {
$xml = simplexml_load_file($feed);
foreach($xml->channel->item as $item) {
$video_title = $item->title;
$video_img=(string) $item->children($ns['content']);
$sql = "INSERT INTO video (video_title, video_img, video_date) VALUES (:video_title, :video_img, NOW())";
$query = $dbh->prepare($sql);
$query->execute(array(
':video_title' => $video_title,
':video_img' => $video_img
));
}
}
你有一個我們可以檢查的在線網址嗎? – Ghost 2014-11-23 09:05:37
@Ghost :)http://axxomovies.org/feed – Dymond 2014-11-23 09:20:56