|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
RSS help please
I have the BBC news feed on my site, however, the BBC website went down today, therefore sending my website down because the operating had timed out.
Is there any code I can use which will allow me to redirect the user to another page if the operation has timed out? This is the bit of code I think it must go with. Code:
Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
xmlHttp.Open "GET", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText
Thanks |
|
#2
|
|||
|
|||
|
I do somethign similar on a site i look after, i pull in the companies twitter feed (xml) and displayit all.
and on ocasions the twitter feed has gone causing the page to go down. my page works differently to yours but what i do is this:- Code:
objXML.Load ("link to rss feed")
isValid = cBool(objXML.parseError.errorCode = 0)
if isValid then
do what ever i need to do because its valid
else
do something because it cant load anything
end if
that basically trys to load the rss/xml feed and if it cant say because its down or there is a problem it will exicute another piece of code, in your case a call to take the person to a different page. hope this helps |
|
#3
|
|||
|
|||
|
Code:
<%
URLToRSS = "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/health/rss.xml"
MaxNumberOfItems = 5
'MainTemplateHeader = "<table>"
'MainTemplateFooter = "</table>"
Keyword1 = ""
Keyword2 = ""
ItemTemplate = "<a href=" & """{LINK} """ & " TARGET='_blank' class='individualsfamileslink'>{TITLE}:</a> {DESCRIPTION} "
ErrorMessage = "Error has occured while trying to process " &URLToRSS & "<BR>Please contact web-master"
Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
'''''''''''''''''xmlhttp.setTimeouts 5000, 60000, 10000, 20000
xmlHttp.Open "GET", URLToRSS, false
xmlHttp.Send()
RSSXML = xmlHttp.ResponseText
Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
xmlDOM.async = False
xmlDOM.validateOnParse = False
xmlDom.resolveExternals = False
If not xmlDOM.LoadXml(RSSXML) Then
ErrorMessage = "Can not load XML:" & vbCRLF & xmlDOM.parseError.reason & vbCRLF & ErrorMessage
End If
Set xmlHttp = Nothing
Set RSSItems = xmlDOM.getElementsByTagName("item")
RSSItemsCount = RSSItems.Length-1
if RSSItemsCount = -1 Then
Set RSSItems = xmlDOM.getElementsByTagName("entry")
RSSItemsCount = RSSItems.Length-1
End If
Set xmlDOM = Nothing
if RSSItemsCount > 0 then
Response.Write MainTemplateHeader
End If
j = -1
For i = 0 To RSSItemsCount
Set RSSItem = RSSItems.Item(i)'
RSSdescription=" "
RSSCommentsLink=" "
for each child in RSSItem.childNodes
Select case lcase(child.nodeName)
case "title"
RSStitle = child.text
case "link"
If child.Attributes.length>0 Then
RSSLink = child.GetAttribute("href")
if (RSSLink <> "") Then
if child.GetAttribute("rel") <> "alternate" Then
RSSLink = ""
End If
End If
End If ' if has attributes
If RSSLink = "" Then
RSSlink = child.text
End If
case "description"
RSSdescription = child.text
case "content" ' atom format
RSSdescription = child.text
case "published"' atom format
RSSDate = child.text
case "pubdate"
RSSDate = child.text
case "comments"
RSSCommentsLink = child.text
case "category"
Set CategoryItems = RSSItem.getElementsByTagName("category")
RSSCategory = ""
for each categoryitem in CategoryItems
if RSSCategory <> "" Then
RSSCategory = RSSCategory & ", "
End If
RSSCategory = RSSCategory & categoryitem.text
Next
End Select
next
'now check filter
If (InStr(RSSTitle,Keyword1)>0) or (InStr(RSSTitle,Keyword2)>0) or (InStr(RSSDescription,Keyword1)>0) or (InStr(RSSDescription,Keyword2)>0) then
j = J+1
if J<MaxNumberOfItems then
ItemContent = Replace(ItemTemplate,"{LINK}",RSSlink)
ItemContent = Replace(ItemContent,"{TITLE}",RSSTitle)
ItemContent = Replace(ItemContent,"{DATE}",RSSDate)
ItemContent = Replace(ItemContent,"{COMMENTSLINK}",RSSCommentsLink)
ItemContent = Replace(ItemContent,"{CATEGORY}",RSSCategory)
Response.Write Replace(ItemContent,"{DESCRIPTION}",RSSDescription)
ItemContent = ""
RSSLink = ""
End if
End If
Next
if RSSItemsCount > 0 then
Response.Write MainTemplateFooter
else
Response.Write ErrorMessage
End If
%>
Thanks for that, that looks good, however I'm not sure how I would implement that into my code |
|
#4
|
|||
|
|||
|
like i said you are doing this a completely different way to how i would do it but to make my way work you woudl add this at thte top fo your page
Code:
URLToRSS = "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/health/rss.xml"
dim objXML
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Load ("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/health/rss.xml")
isValid = cBool(objXML.parseError.errorCode = 0)
if isValid then
then at the bottom of your code add this Code:
else
what ever you want the script to do because an error was found
end if
not the best way to do it, but like i said ive never used the method your currently using so im a little lost |
|
#5
|
|||
|
|||
|
RSS help please
RSS feeds are usually just the headline scrolling across some sort of RSS News Viewer. However, depending on the viewer, you might have a link to click to read more information. Many weblogs make content available in RSS. A news aggregator can help you keep up with all your favorite weblogs by checking their RSS feeds and displaying new items from each of them.
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > RSS help please |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|