Difference between revisions of "6CC001 Workshop - week 06"

From mi-linux
Jump to navigationJump to search
Line 1: Line 1:
 
[[Main Page]] >> [[CP3207|Web Application Development]] >> [[Web Application Developpment - Workbook|Workbook]] >> Week 06
 
[[Main Page]] >> [[CP3207|Web Application Development]] >> [[Web Application Developpment - Workbook|Workbook]] >> Week 06
  
Consuming an existing RSS feed:
+
Today let’s play with RSS feeds. There are 2 things you can do:
 +
 
 +
* Consume an existing third-party feed
 +
* Create your own feed, for other users to consume
 +
 
 +
== Consume an existing third-party feed==
  
 
<pre>
 
<pre>
Line 16: Line 21:
 
     echo $one_item->title."<BR>";  
 
     echo $one_item->title."<BR>";  
 
</pre>
 
</pre>
 +
 +
== Create your own feed, for other users to consume ==

Revision as of 13:30, 28 July 2009

Main Page >> Web Application Development >> Workbook >> Week 06

Today let’s play with RSS feeds. There are 2 things you can do:

  • Consume an existing third-party feed
  • Create your own feed, for other users to consume

Consume an existing third-party feed

  $feed_url = "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml";

  // Get data from feed file
  $response = file_get_contents($feed_url);
    
  // Insert XML into structure
  $xml = simplexml_load_string($response); 

  // Browse structure
  foreach($xml->channel->item as $one_item)
    echo $one_item->title."<BR>"; 

Create your own feed, for other users to consume