I have a script that has been modified from one that I found on the internet
to display RSS feeds in html. The script works fine for most RSS feeds but
there are a number that it fails on with the error "End tag 'head' does not
match the start tag 'meta'".
Does any one on here have any experience with this? The script is shown
below, the Neowin feed works but the google feed does not.
Any help would be appreciated.
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim mydoc, responsexml, strXML, xmlhttp
Dim rss_list, rss_count
url = "http://news.google.co.uk/news?ned=uk&topic=w&output=rss"
' url = "http://www.neowin.net/fb.php?page=all"
'CREATE AN INSTANCE OF THE XMLHTTP OBJECT
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST",url,false
xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xmlhttp.send strXML
responsexml = xmlhttp.responseText
'THE RETURNED TEXT 'responsexml' IS FORMATTED AS AN XML FILE.
'CREATE AN INSTANCE OF THE XML DOCUMENT OBJECT. THIS ENABLE'S YOU TO
MANIPULATE THE RETURNED DOCUMENT
Set mydoc=Server.CreateObject("Microsoft.xmlDOM")
mydoc.loadxml(responsexml)
dim total_node
If (mydoc.parseError.errorCode <0) Then
Dim myErr
Set myErr = mydoc.parseError
rss_feed = "You have error: " & myErr.reason
else
'GET THE NUMBER OF RETURNED NEWS ITEMS
Set NodeList = mydoc.documentElement.selectNodes("channel/item")
total_node = NodeList.length - 1
rss_count = "Total Node: " & NodeList.length
'NOW COLLECT THE NEWS ITEMS AND BUILD AN HTML STRING BLOCK THAT WILL BE
DISPLAYED LATER.
'YOU CAN FORMAT THIS FEED IN ANY WAY YOU WANT!
For x = 0 To total_node
feed = NodeList.Item(x).selectSingleNode("description").T ext
'EXTRACT THE FIRST LETTER OF THE FEED TO FORMAT IT DIFFERENTLY.
' feed_start = left(feed,1)
'EXTRACT THE REST OF THE BODY OF FEED
feed_body = right(feed,len(feed)-1)
if rss_feed <"" then rss_feed = rss_feed & "<hr>"
'GET TITLE
rss_feed = rss_feed & "<strong><h4>" &
NodeList.Item(x).selectSingleNode("title").Text & "</h4></strong>"
' rss_feed = rss_feed & "<span class='style_first_letter'>" & feed_start
& "</span>"
' 'GET BODY
' rss_feed = rss_feed & feed_body
'GET PUBLISHED DATE
rss_feed = rss_feed & "<br><em>Date Published: " &
NodeList.Item(x).selectSingleNode("pubDate").Text & "</em>"
'PROVIDE A 'READ MORE' LINK THAT LINKS TO THE ACTUAL NEWS LINK
rss_feed = rss_feed & "<br>" & "<a href='" &
NodeList.Item(x).selectSingleNode("link").Text & "' target='_blank'>Read
more</a>"
Next
end if
%>
<html>
<head>
<title>My News page</title>
</head>
<body>
<table border="0" cellpadding="5" cellspacing="0" width="100%" align="left">
<tr valign="top">
<td align="left">
<table width="45%" border="1" cellpadding="5" cellspacing="0">
<tr>
<td bgcolor="#FFFFFF"><font size="2" face="Verdana, Arial,
Helvetica, sans-serif">
<%=rss_feed%>
</font></td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>