ASP: Easily Parse and Consume RSS in Classic ASP
This script should work right out of the box.
Note (2025): MSXML 4.0 is long deprecated and no longer supported. If you try this on a modern system, prefer MSXML 6.0 (for example: MSXML2.XMLHTTP.6.0 and MSXML2.DOMDocument.6.0). The example below reflects the original 2006 code for historical accuracy.
1<%
2Call getNews(10)
3
4Sub getNews(howManyResults)
5 myRSSfile = "https://rss.news.yahoo.com/rss/tech"
6
7 Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.4.0")
8 xmlHttp.Open "GET", myRSSfile, False
9 xmlHttp.Send()
10 myXML = xmlHttp.ResponseText
11
12 Set xmlResponse = Server.CreateObject("MSXML2.DomDocument.4.0")
13 xmlResponse.async = False
14 xmlResponse.LoadXml(myXML)
15 Set xmlHttp = Nothing
16
17 Set objLst = xmlResponse.getElementsByTagName("item")
18 Set xmlResponse = Nothing
19
20 intNoOfHeadlines = objLst.length - 1
21
22 For i = 0 To (intNoOfHeadlines)
23 Set objHdl = objLst.item(i)
24
25 For Each child In objHdl.childNodes
26 Select Case LCase(child.nodeName)
27 Case "title"
28 title = child.text
29 Case "link"
30 link = child.text
31 Case "description"
32 description = child.text
33 ' You can also use the following:
34 ' author, category, comments, enclosure, guid, pubDate, source
35 End Select
36 Next
37
38 kk = kk + 1
39 If kk < howManyResults + 1 Then
40 Response.Write "
41" & title & "
42" & description
43 End If
44 Next
45End Sub
46%>