CodeIgniter Forums
I can't read RSS feed from 2 XML in one function. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: I can't read RSS feed from 2 XML in one function. (/thread-46630.html)



I can't read RSS feed from 2 XML in one function. - El Forum - 11-09-2011

[eluser]Unknown[/eluser]
I try to read RSS like this web http://codeigniter.com/wiki/RSSParser but it can read from 1 xml only

This is my Controller
Code:
public function rss_news(){
//Load the shiny new rssparse
$this->load->library('RSSParser', array('url' => 'http://www.manager.co.th/RSS/Home/Breakingnews.xml', 'life' => 0));
//Get six items from the feed
$data = $this->rssparser->getFeed(10);

return $data;
}
public function rss_sport(){
//Load the shiny new rssparse
$this->load->library('RSSParser', array('url' => 'http://www.manager.co.th/rss/sport/sport.xml', 'life' => 0));
//Get six items from the feed
$data = $this->rssparser->getFeed(10);

return $data;
}

public function main_home()
{
$data['rss_news'] = $this->rss_news();
$data['rss_sport'] = $this->rss_sport();

$this->load->view('main_view',$data);
}

This is my View.
Code:
foreach ($rss_news as $item1)
{

echo $item1['title']."<br/>";
}

foreach ($rss_sport as $item2)
{

echo $item2['title']."<br/>";
}

but when I run this code it run function $data['rss_news'] = $this->rss_news(); 2 time.