< Back

Document Subject: Show an RSS feed as HTML
Hint Short Cut: Add this to your code & documentation to help you find this page.
http://#RSStoHTML or http://A555F9/nn.nsf/ByAlias/RSStoHTML

This code can be used to put a RSS news feed on a web page or portal page.




This code can be used in an agent

It can be put on a web page in an iframe, or in a frameset.

A selection of source urls are supplied, these can be found in the source pages of web sites, as alternative URLs.

 

 'OriginalCode by Adam Foster from http://AdFos.com
       'Forlatest version of code goto http://notesninajs.com/#RSStoHTML
       OnError Goto eh
       
       Dimfeed As String
       Dimpos As Long
       Dimnextpos As Long
       
       sourcefile= "http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/front_page/rss.xml" ' BBC Sport
       sourcefile="http://notesninjas.com/A555F9/nn.nsf/rss091!openagent&.xml"' Notes Ninjas
       sourcefile= "http://www.google.com/news?q=nottingham+forest&output=rss"' Google forest news
       sourceFile= "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml"' BBC News
       
       Setsource = CreateObject("Microsoft.XMLDOM")
       source.async= False
       source.load(sourceFile)
       
       feed= source.xml
       
       pos=1
       
       pos=Instr(pos,feed,"<image>")+7      
       
       pos=Instr(pos,feed,"<title>")+7
       nextpos=Instr(pos,feed,"</title>")
       title=Mid(feed,pos,nextpos-pos)
       
       pos=Instr(pos,feed,"<url>")+5
       nextpos=Instr(pos,feed,"</url>")
       url=Mid(feed,pos,nextpos-pos)
       
       pos=Instr(pos,feed,"<link>")+6
       nextpos=Instr(pos,feed,"</link>")
       link=Mid(feed,pos,nextpos-pos)
       
       Print"<center><a target='_blank' href='" & link &"'><img alt='" & title & "' src='" &url & "' border=0></center>"
       
       url_count=1
       DoUntil Instr(pos,feed,"<item>")=0
              pos=Instr(pos,feed,"<item>")+6
             
              pos=Instr(pos,feed,"<title>")+7
              nextpos=Instr(pos,feed,"</title>")
              title=Mid(feed,pos,nextpos-pos)
             
              pos=Instr(pos,feed,"<description>")+13
              nextpos=Instr(pos,feed,"</description>")
              desc=Mid(feed,pos,nextpos-pos)
             
              pos=Instr(pos,feed,"<link>")+6
              nextpos=Instr(pos,feed,"</link>")
              link=Mid(feed,pos,nextpos-pos)
             
              Print "<b><a  target='_blank'href='" & link & "'>"+title+"</a></b><br>"& desc & "<br>"
             
              url_count=url_count+1      
       Loop
       End
eh:
       Print"Error:" & Error$ & "  at line " &Erl