Connecting Tech Pros Worldwide Help | Site Map

dynamicaly parsing a RSS feed to a newsticker applet.

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 09:34 PM
Shogan
Guest
 
Posts: n/a
Default dynamicaly parsing a RSS feed to a newsticker applet.

I stumbled on this capability of javascript by accident.
here's the applet I'm using:
http://javaboutique.internet.com/AdvNewsticker/

feel free to modify to code to apply this capability to any other
method of display you feel like.

and here's the code to do the parsing for the applet.

<HEAD>
<script type="text/javascript">
function RSStoapplet(){

var iMax = 20

var rssDoc = new ActiveXObject("Microsoft.XMLDOM")
rssDoc.async = false
rssDoc.load("YourRSSFeed.xml")

var headNode = rssDoc.selectNodes("/rss/channel")
var itemNodes = rssDoc.selectNodes("/rss/channel/item")

if(itemNodes.length<iMax){
iMax = itemNodes.length
}

document.writeln("<p><center><font color=\"FFFF00\">" +
headNode.item(0).getElementsByTagName("title").ite m(0).text +
"</font></center></p>");
document.writeln("<applet
code=\"http://javaboutique.internet.com/AdvNewsticker/advnewsticker.class\"
width=\"100%\" height=\"27\">");
document.writeln("<param name=\"regcode\" value=\"\">");
document.writeln("<param name=\"info\" value=\"Applet by Gokhan
Dagli,www.appletcollection.com\">");
document.writeln("<param name=\"input_text\"
value=\"from_parameters\">");
document.writeln("<param name=\"text_file\" value=\"\">");
document.writeln("<param name=\"bgcolor\" value=\"000000\">");
document.writeln("<param name=\"text_color\" value=\"FFFF00\">");
document.writeln("<param name=\"highlight_text_color\"
value=\"4876FF\">");
document.writeln("<param name=\"font_type\" value=\"Arial\">");
document.writeln("<param name=\"font_size\" value=\"14\">");
document.writeln("<param name=\"font_style\" value=\"0\">");
document.writeln("<param name=\"underline\" value=\"no\">");
document.writeln("<param name=\"border_thickness\" value=\"1\">");
document.writeln("<param name=\"border_color\" value=\"000000\">");
document.writeln("<param name=\"highlight_border_color\"
value=\"000000\">");
document.writeln("<param name=\"text_align\" value=\"center\">");
document.writeln("<param name=\"xoffset\" value=\"5\">");
document.writeln("<param name=\"yoffset\" value=\"0\">");
document.writeln("<param name=\"pause_time\" value=\"5000\">");
document.writeln("<param name=\"hscroll_delay\" value=\"8\">");
document.writeln("<param name=\"vscroll_delay\" value=\"30\">");
document.writeln("<param name=\"typewriter_delay\" value=\"30\">");
document.writeln("<param name=\"fade_delay\" value=\"100\">");
document.writeln("<param name=\"effects\" value=\"custom\">");
document.writeln("<param name=\"custom_in_effects\" value=\"1\">");
document.writeln("<param name=\"custom_out_effects\" value=\"1\">");
for(i=0;i<iMax;i++){
document.writeln("<param name=\"text" + (i+1) + "\" value=\"" +
itemNodes.item(i).getElementsByTagName("title").it em(0).text + "\">");
document.writeln("<param name=\"link" + (i+1) + "\" value=\"" +
itemNodes.item(i).getElementsByTagName("link").ite m(0).text + "\">");
document.writeln("<param name=\"target_frame1\" value=\"_blank\">");
}
document.writeln("</applet>");
document.writeln("<FORM>");
document.writeln("<div align=\"center\">");
document.writeln("<INPUT TYPE=\"button\" class=\"buttonStyle\"
onClick=\"history.go(0)\" VALUE=\"Reload Page\">");
document.writeln("</div>");
document.writeln("</FORM>");
document.writeln("</body></html>");
}
</script>
</HEAD>
<body bgcolor=000000 onload="setTimeout('history.go(0)',300000);">
<script type="text/javascript">
RSStoapplet();
</script>
</body>


I am having javascript dynamicaly create the html code for the applet
call to include the text into the applet.
Note also that I am refreshing the page every 5 minutes so the news
doesn't get stale.

the code to pull the rss feed and manipulate it came from:
http://www.howtodothings.com/ViewArt...spx?Article=74

this also works but I think mine looks prettier. (sorry if you don't
like the colour scheme)

have fun with this.

Shogan


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.