Steps
What is RSS?
How does RSS syndication work? Say you publish a new web page about a particular topic. You want others interested in that topic to know about it. By listing the page as an "item" in your RSS file, you can have the page appear in front of those who read information using RSS readers or "news aggregators". RSS also allows people to easily add links to your content within their own web pages. Bloggers are a huge core audience that especially does this.
What does RSS stand for? There's a can of worms. RSS as introduced by Netscape in 1999 then later abandoned in 2001 stood for "Rich Site Summary." Another version of RSS pioneered by UserLand Software stands for "Really Simple Syndication." In yet another version, RSS stands for "RDF Site Summary."
History buffs might be interested that there's been some rivalry over who invented RSS. This is why we have both different names and indeed different "flavors" or versions of RSS.
At the heart of an RSS file are "items." No matter what version of RSS you settle on, your file will have to include at least one item. Items are generally web pages that you'd like others to link to. For example, let's say you just created a web page reviewing a new cell phone that's being released. Information about that page would form an item.
To enter your item into the RSS file, you'll need three bits of information:
Title
Description
Link
The title and description of your item need not match exactly the HTML title tag of the web page that the item refers to, nor the meta description tag, assuming you use these. You can write any title and description that you think will describe the page. However, using your page's title and meta description tag certainly makes it easy to copy and paste to build your RSS feed.
In the case of our example page, let's say this is the information we settle on to define it as an item:
Recent Changes - WikiHow
Patrol all the edits that people have recently made to wikiHow!
http://www.wikihow.com/Special:Recentchanges
Now we have to surround that information with xml tags. These are similar to HTML tags, with the exception that unlike with HTML, there's no set definition of xml tags. Anyone can make up a particular xml tag. Whether it is useful depends on the program that reads the resulting xml file. In the case of RSS feeds, they have their own unique set of XML tags that are defined. Use these correctly, and then anything that reads RSS will understand your information.
Did that make your head spin? If so, don't reread - just carry on to see how simple it is. First, open a text editor like Notepad. We're going to build our RSS file using it.
For your title, you need to start it with the title tag, then follow this with the text of the title, then end with the title tag.
For your description, you do the same, starting out with the opening description tag, then following with the actual description, then closing with the description tag.
Next, we add the link information, beginning with link, following with the actual hyperlink, then closing with .
Now there's one more thing we need to do. We actually have to define all this information as forming a particular "item," which we do using a special item tag.
You place the opening item tag, "item" at the top or start of all the information we've listed. You then place the closing item tag, "item", at the bottom or "end" of the item information.
Congratulations! You've now made your first item. There's a bit more to do to finish our RSS file. First, what if we have other items we want to syndicate? Then we simply add more item elements, just as we did above. You can have up to 15 items. New items tend to be inserted at the top, with old items removed from the bottom, to make room for new stuff.
With our example, let's see how things look if we add two more items:
Now, how does something reading our RSS file know that the information above is for our "channel" when it looks just like item information? Simple. As long as we don't surround this information with an opening and closing item tags, it won't be seen as item information but rather as channel information.
There are a few last things we need to do. First, we need to add a tag at the very top of the file saying that this is written according to the XML 1.0 specifications. Right under this, we also have to say what RSS version we are using.
So far, everything we've done is compatible with UserLand's popular RSS 0.91 version. However, it also matches UserLand's latest RSS 2.0 version, as well, so we'll define the file as meeting that specification. This will allow us to add other neat features in the future, if we want.
Finally, after the RSS tag, we need to add an opening "channel" tag. That gives us this at the top of the file:
At the bottom of the file, after all the items we want to syndicate, we have to insert a closing channel and RSS tag, in that order. Those look like this:
This means our complete file looks like this:
Saving The File - Now that we're done adding to the file, we need to save it. But what name shall we give it? As for the first part, that really can be whatever you like. For our example, let's say we just call it "feed.xml".
Now that our file is saved, we can place it anywhere we want on our web server. Let's say we put it in the root or home directory. Then the address to our RSS file would be:
http://www.wikihow.com/feed.xml
Adding the Feed to Your Page - There is one more thing left to do. To make it obvious that you have a feed on your page you should declare it in the head tag on your web page. To do this add the following code:
If everything worked, you should see the little orange RSS icon in your browser's address bar. (Firefox,Opera)
Tips
Getting started will take time and isn't that easy, but after you know the basics it gets easier.
For more technical details on RSS, read the RSS 2.0 specification
4 comments:
情趣用品
煙火
影音視訊聊天室
情趣用品
網頁設計
Thats wonderful and the way you write your post is very much understandable so thank you so much fore this informative and useful post!
web designing
His post is really worth reading. Thanks for you.
Wow there is so much to grab and learn on web development over your blog....
Post a Comment