Morpheusweb.it - Risorse per webmaster: script, ASP.NET, C#, Visual Basic .Net, tutorial, asp, javascript, css, php, html, java, ADO, VBScript, forms, frames, Active Server Pages, Dynamic HTML, database, gratis per webmaster e webdesigner

Feedreader

How to write a feedreader in asp

We can add more feeds, and choose how many items display for each feed. Use the variable "NumFeeds" to set the number of feeds, add add each feed with the code below:


ArrUrls(2) = "http://www.morpheusweb.it/morpheusweb_rss.xml"
ArrNums(2) = 4

Here the code:

<%
Dim NumFeeds
NumFeeds = 3
ReDim ArrUrls(NumFeeds)
ReDim ArrNums(NumFeeds)
ArrUrls(0) = "http://www.corriere.it/rss/homepage.xml"
ArrNums(0) = 2
ArrUrls(1) = "http://www.microsoft.com/italy/msdn/rss.xml"
ArrNums(1) = 2
ArrUrls(2) = "http://www.morpheusweb.it/morpheusweb_rss.xml"
ArrNums(2) = 4
%>
<html>
<head>
<style>
#feedStyle dl {
  font-family:Verdana, Arial, Helvetica, sans-serif;
  width: 280px;
  margin-top: 4px;
  margin-left: 0px;
  padding-bottom: 8px;
  border-top: 10px solid #2C6E91;
  border-bottom: 1px solid #2C6E91;
  background: #FFFFFF;
}
#feedStyle dl dt {
  font-size: 0.8em;
  font-weight: bold;
  color: #E5F4FC;
  text-align: left;
  padding-right: 5px;
  padding-left: 5px;
  border-top: 1px solid #E5F4FC;
  background: #93C1DB;
}
#feedStyle dl dd {
  font-size: 0.8em;
  color: #000;
  line-height: 1em;
  margin-top: 4px;
  margin-left:0px;
  padding-left: 5px;
}
#feedStyle dl dd a, #colMenu dl dd a:visited {
  color: #2C6E91;
  text-decoration: none;
}
#feedStyle dl dd a:hover, #colMenu dl dd a:active {
  color: #2C6E;
  text-decoration: underline;
}
</style>
</head>
<body>
<div id="feedStyle">
<%
For i = 0 to NumFeeds-1
  call PrintFeed(ArrUrls(i),ArrNums(i))
Next
%>
</div>
</body>
</html>
<script language="vbscript" runat="server">
Sub PrintFeed(url,NumNews)
  html = ""
  Set XMLdoc = Server.CreateObject("msxml2.DOMDocument.3.0")
  XMLdoc.async = false
  XMLdoc.setProperty "ServerHTTPRequest", True
  XMLdoc.validateOnParse =false
  XMLdoc.preserveWhiteSpace = false
  Loaded = XMLdoc.Load(url)
  If Loaded Then
    set NodesList = XMLdoc.getElementsByTagName("channel")
    For Each aNode In NodesList
      For Each aNode2 In aNode.childNodes
        Select Case aNode2.nodeName
          Case "title"
            html = html & "<dt>" & aNode2.firstChild.nodevalue & "</dt>"
        End Select
      Next
    Next
    Set NodesList = XMLdoc.getElementsByTagName("item")
    j = 0
    For Each aNode In NodesList
      j = j + 1
      For Each aNode2 In aNode.childNodes
        Select Case aNode2.nodeName
          Case "title"
            strTitle = aNode2.firstChild.nodevalue
          Case "link"
            strURL = aNode2.firstChild.nodevalue
        End Select
      Next
      html = html & "<dd><a target=_blank href=" & strURL & ">" & strTitle & "</a></dd>"
      strTitle = ""
      strURL = ""
      strDescription = ""
      if (j >= NumNews) Then Exit For
    Next
    html = "<dl>" & html & "</dl>"
    set NodesList = Nothing
  End if
  Response.write (html)
End Sub
</script>

Download code...


Print this page


 

Inizio pagina

risorse per webmaster