...

View Full Version : RRS Validation Help Needed.



hughesmi
03-31-2006, 09:01 PM
Hi all.

I need to place some sort of validation around this asp script to say when their is not a www connection it ether re-directs to static page or displays a message saying "off line" Can anyone help me on this one?. The code pulls sports headlines form a rss.



<%
' =========== RSS2HTML.ASP for ASP/ASP.NET ==========
' copyright 2005 (c) www.Bytescout.com
' ===============================================

' =========== configuration =====================
' ##### URL to RSS Feed to display #########
URLToRSS = "http://newsrss.bbc.co.uk/rss/sportonline_uk_edition/football/scot_prem/rss.xml"

' ##### max number of displayed items #####
MaxNumberOfItems = 8

' ##### Main template constants
MainTemplateHeader = "<table>"
MainTemplateFooter = "</table>"
' #####

' ##### Item template.
' ##### {LINK} will be replaced with item link
' ##### {TITLE} will be replaced with item title
' ##### {DESCRIPTION} will be replaced with item description
ItemTemplate = "<tr><td><font face=""Arial"" size=""2""><a href=" & """{LINK}""" & " target=""_blank"">{TITLE}</a><BR>{DESCRIPTION}</font></td></tr>"

' ##### Error message that will be displayed if not items etc
ErrorMessage = "Error has occured while trying to process " &URLToRSS & "<BR>Please contact Mikey."

' ================================================

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 ' uncomment this line if you need to finalize output
%>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum