May 28, 2002

RSS Parser

Download Here

Before I started building a Flash UI for the Movable Type blog, I needed a good collection of XML templates and parsers/converters. The first thing I built was an RSS converter, which allows you to asynchronously load an RSS feed, convert into a data object (for easier handling), and return the object to a callback method.

Here's a snippet from the internal documentation...

AUTHOR: Samuel Wan
DATE: May 2002
DESCRIPTION:
A factory object which parses an XML feed and returns the information
as a data object by passing the object as an argument to a callback
function in the specified callback target. Only works with RSS 0.91
or earlier. For complete documentation, refer to the Actionscript in
the first keyframe of the RSSDataFactory movieclip.

EXAMPLE:
this.receiveRSSObject = function(rssObject)
{ trace("Channel Title: " + rssObject.channels[0].title);
for(var i = 0; i < rssObject.channels[0].items.length; i++)
{ trace("Item Title: " + rssObject.channels[0].items[i].title);
}
}
rssObj = new RSSDataFactory()
rssObj.parseFeed("http://www.samuelwan.com/information/index.xml",
this, "receiveRSSObject");

Posted by samuel at May 28, 2002 05:33 AM
Comments

Sam, I haven't had a chance to check this out yet, but you may want to have the class make the data available as a DataProviderClass, so it could work seamlessly with all of the DataProviderClass aware components.

Posted by: Mike Chambers at May 29, 2002 12:58 AM

Hi,

I tried your RSS converter. On my own machine it works great, but as soon as I put it online, it keeps loading the XML content...
I made a little app which let's you choose an RSS feed, it then shows the titles and then it shows the content including a "read more"link.
It doesn't need any specific MX-server product right? Like Cold Fusion MX Server?
Do you have an idea why it keeps "hanging" on the loading of the RSS feed?
If you'd like, I can send you some code...

Posted by: Frank at May 30, 2002 12:03 AM

hello all,

first of all, Frank, your movie doesn't have rights to access a url diferent from self. You need a server side application, that serves as a point in your domain.

Another quesion, for Mike, do you know where can I find some documentation about DataProviderClass and it's uses ... I see it at Flash components, but I can't understand why I have to use it, as a data model

Thanks for all !

jordi :)

Posted by: jordic at May 30, 2002 03:31 PM

Jordi,

That's weird. If my movie doesn't have rights to access another URL than from it's own domain, how come it works in Flash MX (you know, with ctrl-Enter) and it works if you open the SWF in the Flash player? Is that because of the server?
So, does this mean I need CFMX server to actually get this to work? I dont quite get your'last sentence "You need a server side application, that serves as a point in your domain" You mean serversoftware? Or an app that functions on top of CFMX or IIS?
Hope you can reply to my questions...

Posted by: Frank at May 30, 2002 09:51 PM

Frank, its the Flash MX sandbox that won't allow the SWF to access data from other domains than the one it is on. When you are seeing the SWF in the Flash Player (either by opening the SWF localy, or ctrl-enter in Flah MX) you are watching the SWF on your own computer, and not on a server - when running an SWF (or projector) on your own computer, the sandbox will not stop you from pulling in data from online sources.

There are several ways of getting around the sandbox, the easiest is to make a "Proxy" script on your own server, the script only needs to redirect from the server to the remote data.

I wrote up how to do just that in a post the other day, check it out:
http://weblog.bergersen.net/archives/000169.html

Posted by: jarle at May 30, 2002 10:35 PM

Hey everyone,

Mike made the suggestion of making the RSSObject compatible with DataProviderClass. I'm going to follow his suggestion later this week, and modify the RSSObject hierarchy to use nested DataProviders for channels and channel-items. But first, I'm going to post some new source code for a most interesting project...

-Sam

Posted by: Sam at May 30, 2002 10:51 PM

Frank, just in case the last explanation wasn't clear enough:

Flash's security system doesn't allow online SWFs to access data from domains other than the ones they're on, i.e. you need to hit your own server, not www.yahoo.com or whatever.

This security restriction isn't used when you're running inside the Flash authoring application or when you're running a SWF on your computer outside a browser.

The solution is that you can use any web server to get the info for you:

Your SWF says to your server "get me blah.newsfeeds.com/news.xml" ---> your server says, "ok, I'll go get that file for you" --> your server fetches the data and hands it back to your SWF --> Your SWF gets the data from your server and all is well.

Posted by: Andrew at May 31, 2002 09:58 AM

Andrew, Jarle,

Thanks for clearing that up. I also found that security myself on the MM site. Bummer...
But! Have you seen Phil Chungs RSS Feeder? http://www.philterdesign.com/dev/flashFeeds/ Incredible!

Posted by: Frank at June 3, 2002 11:17 AM

Wow, Phil Chungs' Feeder is pretty slick. Thanks for the link, Frank!

Posted by: Sam at June 3, 2002 07:56 PM

Hello,
thanks for this parser. I tried it on several RSS-Sources and found out, that item an description are empty when containing international chars. Since I want to parse my own channel what do I have to look for when encoding such chars ??

Thanks
Kind regrads Ralf Kuehnbaum

Posted by: Ralf Kuehnbaum at July 15, 2002 03:34 PM

another rss parser (banner like):

http://www.erational.org/software/rssViewer/

Posted by: otomo at August 12, 2002 08:59 AM

Sam I've been searching for a direct communication to you but didn't find an email or any form, that`s why I am writing here. My problem that has to do with MT, XML, and flash, but not directly with your rssDataFactory.
I am from argentina and most of the data I am writing in the MT is in spanish. the problem is that flash isnt parsing the latin charset iso-8859-1.
when I am to write an international character like an accent (í or í) the xml parses Ok but when I load it in the flash doesnt work at all.
If I write only í the flash eats 2 letter after the accent and if i put the option render as html and write down í appears exactly like that í.
I'll be glad if you can post some information about the subject. Thanks.

Posted by: jose at February 19, 2003 03:46 PM

Hey Sam, I just put together an RSS reader using your RSSDataFactory parser. Check it out at: http://www.hollowcube.com/mini_reader

I will be implementing it into my blog at http://www.hollowcube.com/talk/ within the next couple days.

Thanks for the code! :-)

Posted by: michael e. gunn at March 24, 2003 01:50 AM

Hey Michael, that looks small enough to fit on a PDA. Mind if I post this link on the main site?

Posted by: Sam at March 24, 2003 01:57 AM

Hey Sam,

Go right ahead! In fact, if you give me the right dimensions, I can fit it to whatever size you like. Right now this is 200px wide by 300 high. Is this OK?

It currently also allows for searching hollowcube.com, but I'm going to add search functionality through google.com and macromedia's des/dev center.

And the whole thing weighs in at under 16k! :-)

Posted by: michael e. gunn at March 24, 2003 02:13 AM

Just thought this application might be of intrest to you guys:

http://feedreader.com/

Posted by: jc at May 9, 2003 09:55 PM

Hi. How i make a browswer or a Recordset in Flah MX I don't know that it's in XML or PHP(ASP,ColdFusion,...)

Please, help me about it, with some examples of how open table..

Thank you
:D

Posted by: Denis at August 7, 2003 06:47 PM

Hi, I just wanted so say thank you guys ! i really like your site and i hope you'll continue to improving it.

Posted by: viagra at January 25, 2004 12:05 AM
Post a comment









Enter the letters as shown in the box below:



Remember personal info?