Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Server Side Programming > ASP and ASP.NET
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 10-26-2009, 12:06 PM
  #1
ajwposh
Novice (Level 1)
 
Join Date: Oct 2009
Posts: 8
iTrader: (0)
ajwposh is an unknown quantity at this point
Displaying RSS feed

I have some ASP code that displays a BBC news feed.

Code:
URLToRSS = "http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml"
MaxNumberOfItems = 1
'MainTemplateHeader = "<table>"
'MainTemplateFooter = "</table>"

'Keyword1 = "" 
'Keyword2 = ""

ItemTemplate = "<a href=" & """{LINK} """ & " TARGET='_blank' class='individualsfamileslink'>{TITLE}:</a>&nbsp; {DESCRIPTION} &nbsp; &nbsp; "

ErrorMessage = "Error has occured while trying to process " &URLToRSS & "<BR>Please contact web-master"

Set xmlHttp = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
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="&nbsp;" 
RSSCommentsLink="&nbsp;"

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
which i want, however, it seems to display the same story for hours on end, even when a number of new feeds have been added to the bbc website.
Does anyone know any way in which I can maybe display a different feed each time the page is loaded or at least collect the feeds from the bbc website in order of date and when a new feed is added each time.

Thanks
ajwposh is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote

Reply
KEEP TABS
SPONSORS
 
Boxedart
 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 01:51 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.