vrijdag 5 september 2008

Yahoo Pipes Feeds Basics

In this tutorial we will dive into the things you can do to create a valid RSS-feed with Yahoo Pipes. We'll do this in a few easy to understand steps.

Understanding the RSS-format
First of all, it helps if you understand the structure of a valid RSS-feed. If you build a valid feed, you can be sure that most feed readers will process your feed correctly.
Basically, a RSS-feed is nothing more than a text-file, that is formatted in XML. You can examine the contents of the XML-file (and even create your own XML-files) with a simple text-editor like Notepad. Just give it a try: go to the CNN Feeds Page, select the Top Stories Feed by right-clicking on the url (http://rss.cnn.com/rss/edition.rss) and choosing "Save as..." from the popup menu. Now save the file (edition.xml) to your desktop, and open it in Notepad.

A RSS-feed has at the top-level a <rss>-element; subordinate to the <rss> is a single <channel>-element, that holds the meta-data about your feed, such as its name, link, description and more.
Within the <channel>-element, there can be <item>-elements, that contain the the contents of the feed; each article in your feed is represented by an item. The item must at least have a <title> or a <description> element; all other elements are optional.

Below you see an example of the RSS-feed structure:

<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>NAME OF CHANNEL</title>
<link>URL OF CHANNEL</link>
<description>DESCRIPTION OF CHANNEL</description>
<item>
<title>TITLE OF THE FEED ITEM</title>
<link>URL OF ITEM PAGE</link>
<description>SYNOPSIS OF THE ARTICLE</description>
<author>EMAIL OF THE AUTHOR</author>
<pubDate>PUBLICATION DATE AND TIME OF ARTICLE</pubDate>
<guid>UNIQUE ID OF ARTICLE</guid>
<category>CATEGORY OF THE ARTICLE</category>
</item>
</channel>
</rss>



In this example you can see that our <item>-element has 7 elements, that are all useful for feed readers.
The <guid>-element is used by feed readers to avoid duplicates. More about the <guid>-element and how feed readers handle it can be found here.

If you want more information on the RSS 2.0 Specification please visit www.rssboard.org.

Creating a Feed with Yahoo Pipes
Now we will build a sample feed with Yahoo Pipes.
Drag an Item Builder onto the canvas. Add the attributes title, link, description, author, y:published, y:id.value and category. Fill out the fields with real or fake data. You can type them in, except for the y:published-attribute. You first have to build a date with the Date Builder block, and wire its output into the y:published attribute. On connecting the two, select DateTime as the attribute to wire-in.
Now save your pipe, and run it.



Notice that we do NOT use a pubDate-attribute here. Yahoo Pipes uses the y:published-attribute, and outputs it to a pubDate RSS-element. Also notice that you have to use the Date Builder to create the y:published-attribute. Typing in a date will not work.

In the same way, Yahoo Pipes uses the y:id.value-attribute to generate the guid RSS-element. Using a guid-attribute in the Item Builder doesn't work.
If you need help building this pipe, please check out the Tutorial Pipe, and copy one for yourself.

Examine the Feed

In the output-screen of your Pipe, click "More options", then right-click ""Get as RSS" and copy the RRS-link. Paste this link into your feed reader, such as Google Reader or FeedReader(www.feedreader.com).
Or examine its structure (and correctness) with an online Feed Validator.