K
keith_h
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.ziffdavis.com/tech.xml"
'URLToRSS =
"http://stopyouranger.typepad.com/anger_in_the_news/atom.xml"
'URLToRSS =
"http://stopyouranger.typepad.com/anger_in_the_news/index.rdf"
'URLToRSS = "http://www.ajnovickgroup.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 #####
MaxNumberOfItems = 7
' ##### Main template constants
MainTemplateHeader = "<ul class=""leftnav"">"
MainTemplateFooter = "</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.CreateObject("MSXML2.XMLHTTP.3.0")
xmlHttp.Open "Get", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText
Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = false
xmlDOM.LoadXml(RSSXML)
Set xmlHttp = Nothing ' clear HTTP object
Set RSSItems = xmlDOM.getElementsByTagName("item") ' collect all
"items" from downloaded RSS
Set xmlDOM = Nothing ' clear XML
RSSItemsCount = RSSItems.Length-1
' writing Header
if RSSItemsCount > 0 then
Response.Write MainTemplateHeader
End If
j = -1
For i = 0 To RSSItemsCount
Set RSSItem = RSSItems.Item(i)
for each child in RSSItem.childNodes
Select case lcase(child.nodeName)
case "title"
RSStitle = child.text
case "link"
RSSlink = child.text
case "description"
RSSdescription = child.text
End Select
next
j = J+1
if J<MaxNumberOfItems then
ItemContent = Replace(ItemTemplate,"{LINK}",RSSlink)
ItemContent = Replace(ItemContent,"{TITLE}",RSSTitle)
Response.Write Replace(ItemContent,"{DESCRIPTION}",RSSDescription)
ItemContent = ""
End if
Next
' writing Footer
if RSSItemsCount > 0 then
Response.Write MainTemplateFooter
else
Response.Write ErrorMessage
End If
' Response.End
%>
Can anyone tell me what's going on???
Thanks,
--keith
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.ziffdavis.com/tech.xml"
'URLToRSS =
"http://stopyouranger.typepad.com/anger_in_the_news/atom.xml"
'URLToRSS =
"http://stopyouranger.typepad.com/anger_in_the_news/index.rdf"
'URLToRSS = "http://www.ajnovickgroup.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 #####
MaxNumberOfItems = 7
' ##### Main template constants
MainTemplateHeader = "<ul class=""leftnav"">"
MainTemplateFooter = "</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.CreateObject("MSXML2.XMLHTTP.3.0")
xmlHttp.Open "Get", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText
Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = false
xmlDOM.LoadXml(RSSXML)
Set xmlHttp = Nothing ' clear HTTP object
Set RSSItems = xmlDOM.getElementsByTagName("item") ' collect all
"items" from downloaded RSS
Set xmlDOM = Nothing ' clear XML
RSSItemsCount = RSSItems.Length-1
' writing Header
if RSSItemsCount > 0 then
Response.Write MainTemplateHeader
End If
j = -1
For i = 0 To RSSItemsCount
Set RSSItem = RSSItems.Item(i)
for each child in RSSItem.childNodes
Select case lcase(child.nodeName)
case "title"
RSStitle = child.text
case "link"
RSSlink = child.text
case "description"
RSSdescription = child.text
End Select
next
j = J+1
if J<MaxNumberOfItems then
ItemContent = Replace(ItemTemplate,"{LINK}",RSSlink)
ItemContent = Replace(ItemContent,"{TITLE}",RSSTitle)
Response.Write Replace(ItemContent,"{DESCRIPTION}",RSSDescription)
ItemContent = ""
End if
Next
' writing Footer
if RSSItemsCount > 0 then
Response.Write MainTemplateFooter
else
Response.Write ErrorMessage
End If
' Response.End
%>
Can anyone tell me what's going on???
Thanks,
--keith