Rein Dolfing

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromRein Dolfing
ToMe
SubjectHow can I reuse the parseRSS newsitems-array ?
Date2 August 2005 13:49
Attachmentzip file of test page
Hi,

I finally found a script that could parse a RSSfeed in javascript on your
site. GREAT !!
I would like to use the script on our intranet to promote the use and show
the power of RSS feeds just as demo.
I managed to get things working as a HTML-page. (parsRSS()code  and
display-code in one HTML page)

I now work on a scroller-script that uses a (local)RSSfeed as input.
I choose the "Mikescroll"-script because it handles FireFox/Mozilla and
IE5+. Furthermore I like the "modular"-approach of the script.
 
To keep the solution "modular" I decided to separate the parseRSS()code and
the display-code in different files.

Now I run into the problem: "How can I access the newsItems-array that is
the result of parseRSS()."
I tried several options ( due to lack of Javascript language knowledge ).

The NewsItems-array is global defined in parseRSS.js, but I can't access it
from RSS-scroller.html.
I attached the source files.
 
Could/Would you take a look at the code please ?.


Yours sincerely,
	Rein Dolfing
FromRein Dolfing
ToMe
SubjectHow can I reuse the parseRSS newsitems-array ?
Date3 August 2005 14:58
Attachmentzip file of test page
Hi,

Sorry, the RSSscroll.zip misses an RSS xml file.
This file is now included, the demo should be complete now.

I managed to get the Scroller working in IE 5+.
I changed parseRRS.js, the code that builds the "newsItem" array, created a
local copy of the array.

But it still doesn't work in Mozilla/FireFox.
Because you pay special attention to browser-compatibility I thought I let
you know.
 ( and of course I would like to know what I did wrong !).
In the RSS-Scroller.html I included an "alert "message to show the number of
items read from the feed.
IE 5+ says 8,  Firefox/Mozilla  says 0.


Yours sincerely,
	Rein Dolfing
FromMe
ToRein Dolfing
SubjectRe: How can I reuse the parseRSS newsitems-array ?
Date4 August 2005 23:49
Rein,

> I now work on a scroller-script that uses a (local)RSSfeed as input.
> I choose the "Mikescroll"-script
> because it handles FireFox/Mozilla and IE5+.

but it fails in Opera, making it totally useless for me, since I am an Opera
user :)

[snip]

Now, on to your problem.

> importXML('nieuws-nu.xml','parseRSS');
> alert ("items: " + newsItems.length );

Of course it fails. You haven't let it load yet.
XML files do not load immediately. They load asynchronously in another
thread. Once the parseRSS function has finished, it will be ready (IE will
show the same response over slower connections). You should only attempt to
populate and start the scroller inside the end of the parseRSS function.

Please consult the author of the scroller script for more details on how to
delay starting of the scroller.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromRein Dolfing
ToMe
SubjectHow can I reuse the parseRSS newsitems-array ?
Date5 August 2005 14:43
Hi Mark,

Sorry for that "Opera-thing", but not everybody is free to choose the
browser he/she would like to use.

[snip]

Your statement "Of course it fails. You haven't let it load yet".....
Did point me in the right direction.

I moved the code that adds the Scroller-items into the "RSSscroll" routine.

The "windows.onload=RSSscroll" seems to produce enough delay to let
importXML(...) end the import.
It works for me now.( FireFox/Mozilla and IE5+ )

PS.
I attached the working code, so you can try it in Opera if you like.


Thanks for your response, support & time.

Yours sincerely,
	Rein Dolfing
FromMe
ToRein Dolfing
SubjectRe: How can I reuse the parseRSS newsitems-array ?
Date7 August 2005 02:58
Attachmentfixed version of the page
Rein,

> I moved the code that adds the Scroller-items into the "RSSscroll"
> routine.

hmm, still seems to be heading for problems. the RSSscroll() command is
being called as soon as the main page has loaded, but that might be before
the XML document has loaded.

If the XML file loads too slowly, or the main page loads too fast, all you
will get is the word "undefined" in the scroller.

You should not run RSSscroll() onload, you should run it at the end of the
parseRSS function (since that is only called after the XML file has loaded).
That is the only way to guarentee that the XML file has loaded.

Also, you should not try importing the XML until after you have created the
scroller, or you risk the XML file loading so fast that it has loaded before
the RSSscroll() function has been defined.

> I attached the working code, so you can try it in Opera if you like.

You can try it too - Opera is free and cross platform, available from
http://www.opera.com/download/

Ah, I forgot to mention, you also have to remove the stupid browser sniff in
the scroller code that stupidly stops Opera from running it. Honestly that
script is dumb. It still deliberately blocks Opera. Looks like it was trying
to protect Opera 6, but Opera is now at version 8 and has been capable of
running that script since Opera 7 was released in January 2003.

DynamicDrive (and the original author of the script) should be ashamed of
themselves for not keeping their scripts up to date [Ed. I have contacted
them and sent them details of the mistaken blocking]. Oh well, such is life.
Anyway, the fix is to change:
var dom=document.getElementById&&!ie&&navigator.userAgent.indexOf("Opera")==-1
to:
var dom=document.getElementById&&!ie&&document.childNodes&&document.createElement
in the file dhtmllib.js


I have attached a zip file with all the required modifications to make it
run reliably in everything.


Tarquin
FromRein Dolfing
ToMe
SubjectHow can I reuse the parseRSS newsitems-array ?
Date8 August 2005 09:34
Hi Mark,

Great.

Again. thanks for your response, support & time.

Yours sincerely,
	Rein Dolfing
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.