I am trying to create an ASP.NET application that
consumes an RSS Newsfeed from Yahoo News
(http://rss.news.yahoo.com/rss/topstories). I keep
getting the following error message, even though my code
seems corect. In fact, when I drop virtually the same
code into a Windows Forms application using VB.NET and
use a Windows Forms datagrid, I get the xml from the
newsfeed without any problem.
Here is the error message:
"The 'META' start tag on line '1' doesn't match the end
tag of 'HEAD' in file
http://rss.news.yahoo. com/rss/topstories'. Line 1,
position 135."
Here is my code from my ASPX page:
<%@ Import Namespace="Syst em.Data" %>
<%@ Import Namespace="Syst em.Xml" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN">
<HTML>
<HEAD>
<title>Yahoo! News Top Stories</title>
<meta name="GENERATOR " content="Micros oft Visual
Studio .NET 7.1">
<meta name="CODE_LANG UAGE" content="Visual Basic .NET
7.1">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<script language="VB" runat="server">
Private Const YAHOO_RSS_FEED As String
= "http://rss.news.yahoo. com/rss/topstories"
Sub Page_Load(sende r as Object, e as EventArgs)
'Cache the top stories for 20 minutes
If Cache("YahooTop Stories") Is Nothing then
'Item not in cache, get it manually
Dim dt as DataTable = GetRSSFeed(YAHO O_RSS_FEED)
Cache.Insert("Y ahooTopStories" , dt, Nothing,
DateTime.Now.Ad dMinutes(20), TimeSpan.Zero)
End If
topStories.Data Source = Cache("YahooTop Stories")
topStories.Data Bind()
End Sub
Function GetRSSFeed(strU RL as String) as DataTable
'Get the XML data
Dim reader as XmlTextReader = New XmlTextReader
(strURL)
'return a new DataSet
Dim ds as DataSet = New DataSet()
ds.ReadXml(read er)
Return ds.Tables(2)
End Function
</script>
<asp:DataGrid runat="server" id="topStories "
AutoGenerateCol umns="False"
Font-Name="Arial" Font-Size="10pt"
HeaderStyle-Font-Bold="True"
HeaderStyle-HorizontalAlign ="Center"
HeaderStyle-BackColor="Navy " HeaderStyle-
ForeColor="Whit e"
HeaderStyle-Font-Size="15pt"
AlternatingItem Style-BackColor="#eee eee">
<Columns>
<asp:TemplateCo lumn HeaderText="Yah oo News Top
Stories for <%=Today()%>" >
<ItemTemplate >
<a href="<%# DataBinder.Eval
(Container.Data Item, "link")%>">
<%# DataBinder.Eval
(Container.Data Item, "title") %>
</a> <!--(<i><%# DataBinder.Eval
(Container.Data Item, "datePosted ") %></i>)-->
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
</body>
</HTML>
Do you know what I need to change?
Thanks in advance.