0
votes

I'm working on a rss feed reader and seems so work great. The only thing that I seem not to get working is to read the image in the feed.

<itunes:image href="http://www.itunes.com/image.jpg"/>

Can anyone help?

This is a part of my code.

  For Each objItem in objItems
      On Error Resume Next
      TheTitle =  objItem.selectSingleNode("title").Text
      TheLink =  objItem.selectSingleNode("image").Text
      Theimg =  objItem.SelectSingleNode("itunes").Attributes(":image").InnerText

      Response.Write "<div class='article'>" &_
                     "<a href=" & TheLink & ">" & _
                     "<span>" & Theimg & TheTitle & "</span>" & _
                     "</a>" & _
                     "</div>"
 Next
1

1 Answers

0
votes

Your image address needs to go inside an image tag

Response.Write "<div class=""article"">" &_
                 "<a href=""" & TheLink & """>" & _
                 "<img src=""" & Theimg & """ alt=""" & TheTitle & """ />"  & _
                 "</a>" & _
                 "</div>"

If you're wondering why all the double quotes, see this question

Adding quotes to a string in VBScript

As an aside, if you understand XSL then I find that the best way to handle RSS feeds in Classic ASP is to do a server side XSLT transformation. The ASP looks like this

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