日期:2014-05-17 浏览次数:20535 次
<?php
require_once('magpierss/rss_fetch.inc');
$url = "http://localhost/PHPProject/RSS/RSS.xml";
$rss = fetch_rss($url);
$feedTitle = $rss->channel['title'];
echo '<p>Latest News from <strong>' . $feedTitle . '</strong></p>';
foreach ($rss->item as $it) {
$link = $it['link'];
$title = $it['title'];
$description = isset($it['description']) ? $it['description'] : '';
echo '<p><a href=\"$link\">' . $title . '</a><br />' . $description . '</p>';
}
?>
<?xml version="1.0" encoding="UTF-8" ?> - <rss version="2.0"> - <channel> <title>XHTML</title> <link>http://localhost/PHPProject/NewFile.html</link> <description>Free web building tutorials</description> <category>Web development</category> <language>en-US</language> <copyright>2006 w3school.com.cn. All rights reserved.</copyright> - <item> <title>RSS Tutorial</title> <link>http://localhost/PHPProject/NewFile.html</link> <description>New RSS tutorial on W3School</description> <author>service@w3school.com.cn</author> <comments>http://localhost/PHPProject/NewFile.html</comments> </item> </channel> </rss>
<channel>
...
<item>...</item>
<item>...</item>
<!-- 可能有多个 -->
</channel>
------解决方案--------------------