M
mark r
Trying to create a page like popurls displaying rss feeds from music
sites only im trying with one to start from NME.com and the output
errors with the message "Whitespace is not allowed at this location."
anyone help?
DEMO: http://mngr.co.uk/rss1.asp
Code:
<%@ Language="VBScript" %>
<% Option Explicit %>
<% Response.Charset = "UTF-8" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>ASP 101's MegaTokyo RSS Feed Reader</title>
</head>
<body>
<%
If DateDiff("h", Application("MegaTokyoUpdated"), Now()) >= 2 _
Or Request.QueryString("force") <> "" Then
Dim objXML
Dim objItemList
Dim objItem
Dim strHTML
Set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
objXML.async = False
objXML.setProperty "ServerHTTPRequest", True
objXML.Load("http://nme.com/rss/news.xml")
'objXML.Load(Server.MapPath("megatokyo.xml"))
If objXML.parseError.errorCode <> 0 Then
Response.Write "<pre>" & vbCrLf
Response.Write "<strong>Error:</strong> " &
objXML.parseError.reason
Response.Write "<strong>Line:</strong> " &
objXML.parseError.line & vbCrLf
Response.Write "<strong>Text:</strong> " _
& Server.HTMLEncode(objXML.parseError.srcText) & vbCrLf
Response.Write "</pre>" & vbCrLf
End If
Set objItemList = objXML.getElementsByTagName("item")
Set objXML = Nothing
For Each objItem In objItemList
' MegaTokyo Feed childNodes: 0=title, 1=link, 2=description
strHTML = strHTML & "<p>" & vbCrLf
strHTML = strHTML & "<a href=""" & objItem.childNodes(1).text &
""">"
strHTML = strHTML & "<strong><em>" & objItem.childNodes(0).text
strHTML = strHTML & "</em></strong></a><br />" & vbCrLf
strHTML = strHTML & Replace(objItem.childNodes(2).text, "<br>",
"<br />") & vbCrLf
strHTML = strHTML & "</p>" & vbCrLf
Next
Set objItemList = Nothing
Application.Lock
Application("MegaTokyoContent") = strHTML
Application("MegaTokyoUpdated") = Now()
Application.UnLock
End If
%>
<%= Application("MegaTokyoContent") %>
<!--<%= Application("MegaTokyoUpdated") %>-->
</body>
</html>
sites only im trying with one to start from NME.com and the output
errors with the message "Whitespace is not allowed at this location."
anyone help?
DEMO: http://mngr.co.uk/rss1.asp
Code:
<%@ Language="VBScript" %>
<% Option Explicit %>
<% Response.Charset = "UTF-8" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>ASP 101's MegaTokyo RSS Feed Reader</title>
</head>
<body>
<%
If DateDiff("h", Application("MegaTokyoUpdated"), Now()) >= 2 _
Or Request.QueryString("force") <> "" Then
Dim objXML
Dim objItemList
Dim objItem
Dim strHTML
Set objXML = Server.CreateObject("MSXML2.FreeThreadedDOMDocument")
objXML.async = False
objXML.setProperty "ServerHTTPRequest", True
objXML.Load("http://nme.com/rss/news.xml")
'objXML.Load(Server.MapPath("megatokyo.xml"))
If objXML.parseError.errorCode <> 0 Then
Response.Write "<pre>" & vbCrLf
Response.Write "<strong>Error:</strong> " &
objXML.parseError.reason
Response.Write "<strong>Line:</strong> " &
objXML.parseError.line & vbCrLf
Response.Write "<strong>Text:</strong> " _
& Server.HTMLEncode(objXML.parseError.srcText) & vbCrLf
Response.Write "</pre>" & vbCrLf
End If
Set objItemList = objXML.getElementsByTagName("item")
Set objXML = Nothing
For Each objItem In objItemList
' MegaTokyo Feed childNodes: 0=title, 1=link, 2=description
strHTML = strHTML & "<p>" & vbCrLf
strHTML = strHTML & "<a href=""" & objItem.childNodes(1).text &
""">"
strHTML = strHTML & "<strong><em>" & objItem.childNodes(0).text
strHTML = strHTML & "</em></strong></a><br />" & vbCrLf
strHTML = strHTML & Replace(objItem.childNodes(2).text, "<br>",
"<br />") & vbCrLf
strHTML = strHTML & "</p>" & vbCrLf
Next
Set objItemList = Nothing
Application.Lock
Application("MegaTokyoContent") = strHTML
Application("MegaTokyoUpdated") = Now()
Application.UnLock
End If
%>
<%= Application("MegaTokyoContent") %>
<!--<%= Application("MegaTokyoUpdated") %>-->
</body>
</html>