想在RSS Parser Library代码中添加内容编码

时间:2013-03-15 08:47:50

标签: php codeigniter rss encode rss-reader

我正在使用CodeIgniter和RSS Parser Library。我对这段代码很满意。

  

function get_ars(){       //加载RSS Parser       $这 - >负载>库( 'rssparser');

// Get 6 items from arstechnica
$rss = $this->rssparser->set_feed_url('http://feeds.arstechnica.com/arstechnica/index/')->set_cache_life(30)->getFeed(6);

foreach ($rss as $item)
{
    echo $item['title'];
    echo $item['description'];
} }

但我想为内容编码添加更多内容。但我不知道该怎么做。

1 个答案:

答案 0 :(得分:1)

我在http://blog.stuartherbert.com/php/2007/01/07/using-simplexml-to-parse-rss-feeds/找到了解决方案 打开应用程序/库/ Rssparser.php。 转到第107行 添加Follwing声明。

$ns = $xml->getNamespaces(true);
$content = $item->children($ns['content']);
$data['content'] = (string) trim($content->encoded);

你可以使用

echo $item['content'];
在您的视图文件中

相关问题