I am primarily a front-end designer and not familiar with ASP beyond
breaking up pages into include files. Recently, one of my freelance
clients wanted to display an RSS feed from his blog on his site. I did
some research and found the rss2html.asp script. I chose this over a
javascript solution because those scripts apparently don't affect
search engine rankings.
I implemented the script and it was running fine until about a month
ago, when the site and sometimes the server running it started to
crash. The ISP and the blog company the RSS feed originates from blame
the script. Bytescout, who wrote the script, says that it's probably
the feed that's causing the problem. The RDF version of the feed
validates as RSS, but the ATOM one has specs that are too new for the
validator to parse correctly.
I'm inclined to think that the way I implemented the script is causing
the problem. I'll post it below:
<%
' =========== RSS2HTML.ASP for ASP/ASP.NET ==========
' copyright 2005 (c) www.Bytescout.com
' =============== =============== =============== ==
' =========== configuration =============== ======
' ##### URL to RSS Feed to display #########
'URLToRSS = "http://rssnewsapps.zif fdavis.com/tech.xml"
'URLToRSS =
"http://stopyouranger.t ypepad.com/anger_in_the_ne ws/atom.xml"
'URLToRSS =
"http://stopyouranger.t ypepad.com/anger_in_the_ne ws/index.rdf"
'URLToRSS = "http://www.ajnovickgro up.com/weblog/atom.xml"
'URLToRSS = "http://www.rssmix.com/u/4592/rss.xml"
URLToRSS = "http://www.feedjumbler .com/ea511d86/rss.xml"
' ##### max number of displayed items #####
MaxNumberOfItem s = 7
' ##### Main template constants
MainTemplateHea der = "<ul class=""leftnav "">"
MainTemplateFoo ter = "</ul>"
' #####
' ##### Item template.
' ##### {LINK} will be replaced with item link
' ##### {TITLE} will be replaced with item title
' ##### {DESCRIPTION} will be replaced with item description
ItemTemplate = "<li><a href=" & """{LINK}"" " & ">{TITLE}</a></li>"
' ##### Error message that will be displayed if not items etc
ErrorMessage = "<p>Feed temporarily unavailable.<br /> Please try
again later.</p>"
' =============== =============== =============== ===
Set xmlHttp = Server.CreateOb ject("MSXML2.XM LHTTP.3.0")
xmlHttp.Open "Get", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.Respons eText
Set xmlDOM = Server.CreateOb ject("MSXML2.Do mDocument.3.0")
xmlDOM.async = false
xmlDOM.LoadXml( RSSXML)
Set xmlHttp = Nothing ' clear HTTP object
Set RSSItems = xmlDOM.getEleme ntsByTagName("i tem") ' collect all
"items" from downloaded RSS
Set xmlDOM = Nothing ' clear XML
RSSItemsCount = RSSItems.Length-1
' writing Header
if RSSItemsCount > 0 then
Response.Write MainTemplateHea der
End If
j = -1
For i = 0 To RSSItemsCount
Set RSSItem = RSSItems.Item(i )
for each child in RSSItem.childNo des
Select case lcase(child.nod eName)
case "title"
RSStitle = child.text
case "link"
RSSlink = child.text
case "descriptio n"
RSSdescription = child.text
End Select
next
j = J+1
if J<MaxNumberOfIt ems then
ItemContent = Replace(ItemTem plate,"{LINK}", RSSlink)
ItemContent = Replace(ItemCon tent,"{TITLE}", RSSTitle)
Response.Write Replace(ItemCon tent,"{DESCRIPT ION}",RSSDescri ption)
ItemContent = ""
End if
Next
' writing Footer
if RSSItemsCount > 0 then
Response.Write MainTemplateFoo ter
else
Response.Write ErrorMessage
End If
' Response.End
%>
Can anyone tell me what's going on???
Thanks,
--keith