• support[@]kurinchilion.com
  • +1 (888) 666-4252

Tags

CakePHP: Parsing RSS feed in Simple Steps

Jun 05, 2009 - by kurinchilamp / / Post Comment
How to read RSS feeds (XML file) and display contents in CakePHP? Parsing an XML feed can be done in simple steps as follows in CakePHP ... CakePHP Controller: /app/controllers/rss_controller.php
<?php
/**
*	CakePHP Controller to parse XML file
*/
class RssController extends AppController{
	var $name = "Rss";
	// As the RSS will not currently use a database
	var $uses = array();
	var $feed_url = "http://kurinchilamp.kurinchilion.com/feed";
	var $rss_item = array();
	
	function index(){
		App::import('Xml');
		$parsed_xml =& new XML($this->feed_url);
		// xml to array conversion
		$this->rss_item = $parsed_xml->toArray();
		$this->set('data', $this->rss_item['Rss']['Channel']['Item']);
	}
}
?>

CakePHP View: /app/views/rss/index.ctp



Continue Reading

TECHNOLOGY DEV STACK

Following are some of the technologies that we use to build and maintain solutions for our clients.