B
blackstaronline.net
Here is my working code to pull Yahoo business news RSS feed. Can
anyone show me how to only return the top 3 or 4 news articles?
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
If Cache("RSS1") Is Nothing then
Dim dt as DataTable =
GetRSSFeed("http://rss.news.yahoo.com/rss/business")
Cache.Insert("RSS1", dt, Nothing, DateTime.Now.AddMinutes(180),
TimeSpan.Zero)
End If
rss.DataSource = Cache("RSS1")
rss.DataBind()
End Sub
Function GetRSSFeed(strURL as String) as DataTable
Dim reader as XmlTextReader = New XmlTextReader(strURL)
Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)
Return ds.Tables(3)
End Function
</script>
<aspataList runat="server" id="rss">
<itemtemplate>
<font size="2" face="Geneva, Arial, Helvetica, san-serif"><b><a
href="<%# DataBinder.Eval(Container.DataItem, "link") %>"
target="_blank"><%# DataBinder.Eval(Container.DataItem, "title")
%></a></b><br />
<%# DataBinder.Eval(Container.DataItem, "description")
%></font><br />
</itemtemplate>
</aspataList>
Thanks in advance,
Jeremy Reid
http://hgtit.com
anyone show me how to only return the top 3 or 4 news articles?
<%@ Import Namespace="System.Xml" %>
<script language="VB" runat="server">
Public Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs)
If Cache("RSS1") Is Nothing then
Dim dt as DataTable =
GetRSSFeed("http://rss.news.yahoo.com/rss/business")
Cache.Insert("RSS1", dt, Nothing, DateTime.Now.AddMinutes(180),
TimeSpan.Zero)
End If
rss.DataSource = Cache("RSS1")
rss.DataBind()
End Sub
Function GetRSSFeed(strURL as String) as DataTable
Dim reader as XmlTextReader = New XmlTextReader(strURL)
Dim ds as DataSet = New DataSet()
ds.ReadXml(reader)
Return ds.Tables(3)
End Function
</script>
<aspataList runat="server" id="rss">
<itemtemplate>
<font size="2" face="Geneva, Arial, Helvetica, san-serif"><b><a
href="<%# DataBinder.Eval(Container.DataItem, "link") %>"
target="_blank"><%# DataBinder.Eval(Container.DataItem, "title")
%></a></b><br />
<%# DataBinder.Eval(Container.DataItem, "description")
%></font><br />
</itemtemplate>
</aspataList>
Thanks in advance,
Jeremy Reid
http://hgtit.com