View Full Version : displaying RSS feeds in HTML

07-18-2007, 10:54 PM
Hello. I'm just trying to take an RSS feed and have it appear on an HTML page - not in an iframe, target window or anything like that, but rather just as regular, controllable body text on a specified part of the page, like in table cell or a div. I searched the archives a bit, and I found a couple of things about this, like from noname1122 in March 04 and madmatter23 in June 07, but their codes don't seem to work at all. I need javascript/DHTML - can't go with a PHP solution. Can anyone help? Thanks, and let me know if I'm not in the right sub-forum here. Appreciate it, y'all.

rnd me
07-19-2007, 04:14 AM
you know that you can only use feeds that are hosted on the same domain as your page right?

provided same domains, your choices for inlining and rss feed are:
-inIE - use an <XML> tag to import and style the data
-AJAX the rss file, and process the responseXml in javascript.
-perform a client-side XSLT transform that outputs javascript, and use DOM methods to work that into to page content.
-use XSLT transforms to produce the entire page from an RSS file.
-use FireFox2's XML data type in combination with e4x to produce the html blocks.

i am sure i forgot a couple of other possibilities here, but googlin the above topics should get you on your way.

07-19-2007, 04:19 PM
(replied twice by accident)

07-19-2007, 04:20 PM
Hello rnd! Thanks for the help so far. I found a site (http://www.howtocreate.co.uk/tutorials/jsexamples/rss.html) that seems to offer that third solution. But it seems to do more than I want or need. Let me rephrase my question.

All I'm trying to do is have a portion of an RSS feed - the header, first words of a new entry, etc. - appear on my page as the linked text in a regular HTML link. That's it. The link itself could open up a new page or whatever. The other page to be read (and then linked to) is a blog, in XHTML code, or so it says. (it's a Blogger.com page).

A blogger.com page is not in my domain, of course. I'm not clear why that's important - isn't the purpose of RSS to read/publish to other pages? Also, I have feedreader 3.10, but I don't think I need to involve that in this process - correct me if I'm wrong.

In short, I'm just looking for some code that will read a specified RSS text upon page load, and take that text and stick it in between the angle brackets in a link <a href="*"> (RSS feed here) </a>. Nothing more. Hope that helps clarify, and thanks for being patient with a newbie. :o

rnd me
07-20-2007, 05:34 AM
A blogger.com page is not in my domain, of course. I'm not clear why that's important - isn't the purpose of RSS to read/publish to other pages?

This is important because the tools used to retrieve the rss feed on the client-side are themselves restricted to a single domain, particularly the xmlHttpRequest object. While true that the intent and spirit of rss is a free-flow of information, browsers have yet to embrace and facilitate this flow.

There are however several possible workarounds. The old standard was using your own server to escape/xslt the code into javascript, which can then come from any domain. A free and easy workaround is now available through yahoo pipes. you can easily add multiple rss feeds into one, and retrive the combined stream as JSON.
JSON can come from anywhere, whereas XML must come from you.

Another workaround i don't hear much about, but have used in past uses a client-side page to mimic the functionality of a server. If the data doesn't change every 30 seconds (most feeds don't), you might consider simulating a server on you own pc. Active desktop webpages can pull data from any domain. The page should then convert the xml to json, and upload it to your server. Use a setTimeout or a meta-refresh to reset the page, and have the update bound to onload.

If i were just getting started, i would checkout yahoo pipes first. i think they even have examples of what you want to do.

you can also use a google widget to accomplish the same thing if you don't mind a small logo.

i think that once you overcome the 'domain dilema' you should have little trouble finding examples of json>html.

ex: document.getElementById("rssLink1").innerHTML=RSS.item[0].title

i hope this helps somewhat, i've been down the same path, and know it can be a bear.