1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect1 id="zend.feed.introduction">
4 <title>Introduction</title>
7 <classname>Zend_Feed</classname> provides functionality for consuming <acronym>RSS</acronym>
8 and Atom feeds. It provides a natural syntax for accessing elements of feeds, feed
9 attributes, and entry attributes. <classname>Zend_Feed</classname> also has extensive
10 support for modifying feed and entry structure with the same natural syntax, and turning the
11 result back into <acronym>XML</acronym>. In the future, this modification support could
12 provide support for the Atom Publishing Protocol.
16 Programmatically, <classname>Zend_Feed</classname> consists of a base
17 <classname>Zend_Feed</classname> class, abstract <classname>Zend_Feed_Abstract</classname>
18 and <classname>Zend_Feed_Entry_Abstract</classname> base classes for representing Feeds and
19 Entries, specific implementations of feeds and entries for <acronym>RSS</acronym> and Atom,
20 and a behind-the-scenes helper for making the natural syntax magic work.
24 In the example below, we demonstrate a simple use case of retrieving an
25 <acronym>RSS</acronym> feed and saving relevant portions of the feed data to a simple
26 <acronym>PHP</acronym> array, which could then be used for printing the data, storing to a
31 <title>Be aware</title>
34 Many <acronym>RSS</acronym> feeds have different channel and item properties available.
35 The <acronym>RSS</acronym> specification provides for many optional properties, so be
36 aware of this when writing code to work with <acronym>RSS</acronym> data.
40 <example id="zend.feed.introduction.example.rss">
41 <title>Putting Zend_Feed to Work on RSS Feed Data</title>
43 <programlisting language="php"><![CDATA[
44 // Fetch the latest Slashdot headlines
47 Zend_Feed::import('http://rss.slashdot.org/Slashdot/slashdot');
48 } catch (Zend_Feed_Exception $e) {
50 echo "Exception caught importing feed: {$e->getMessage()}\n";
54 // Initialize the channel data array
56 'title' => $slashdotRss->title(),
57 'link' => $slashdotRss->link(),
58 'description' => $slashdotRss->description(),
62 // Loop over each channel item and store relevant data
63 foreach ($slashdotRss as $item) {
64 $channel['items'][] = array(
65 'title' => $item->title(),
66 'link' => $item->link(),
67 'description' => $item->description()