ASP Classic reading XML Feed

I am having trouble reading the following feed. http://www.whatsonincapetown.com/feed/

my code is as follows:

<%

TheFeed = "http://www.whatsonincapetown.com/feed/"

Set xmlDOM = Server.CreateObject("MSXML2.DOMDocument")
xmlDOM.async = False
xmlDOM.setProperty "ServerHTTPRequest", True
xmlDOM.Load("TheFeed")

Set itemList = XMLDom.SelectNodes("rss[1]/channel/item") 

myCount = 0
response.write "Getting Cape Town News Feed."
For Each itemAttrib In itemList
    myCount = myCount + 1
    response.write (myCount)
    newsSubject =itemAttrib.SelectSingleNode("title").text
    newsExtract =itemAttrib.SelectSingleNode("description").text
    newsDate =itemAttrib.SelectSingleNode("pubDate").text
    %>
    <tr>
        <td><%=newsSubject%></td>
        <td><%=newsDate%></td>
        <td><%=newsExtract%></td>
    </tr>
    <%
Next

Set xmlDOM = Nothing
Set itemList = Nothing

%>

Anyone have any idea why it is not able to parse the feed, and is not giving any form of error.

Answers


Try and change

xmlDOM.Load("TheFeed")

to

xmlDOM.Load(TheFeed)

because TheFeed is a variable, not a string :-)


There's an asp script to read RSS feeds here. The comments are in Danish but that shouldn't be a problem if you understand VBS.

https://web.archive.org/web/20050517002557/http://www.html.dk/scripts/asp/00020/

However IMO the best way to parse XML with Classic ASP is to use an XSL Stylesheet. Your ASP code would look like this.

set xml = Server.CreateObject("Msxml2.DomDocument.6.0")
  xml.setProperty "ServerHTTPRequest", true
  xml.async = false
  xml.validateOnParse = false
  xml.load("http://yourfeed")
  set xsl = Server.CreateObject("Msxml2.DomDocument.6.0")
  xsl.load(Server.Mappath("yourstylesheet.xsl"))
  Response.Write(xml.transformNode(xsl))
  set xsl = nothing
  set xml = nothing

You should be able to find a ready made rss reader xsl document online somewhere


Need Your Help

How to put 2 lists into 1 Dictionary in Python?

python

So this is the situation: I have 2 lists and want to put them in a dictionary.

Entity Framework Add Performance Degrades With More Rows

c# asp.net performance linq entity-framework

I'll begin this post by noting that I'm entirely new to the .NET world. ASP, EntityFramework, Linq, etc. are all mostly unknown magic at this point.