问题描述
您好.我正在使用RSS数据源(由asp.net的rsstoolkit提供)以检索最新报纸文章的列表并将其显示在列表视图中.我有三个要检索的URL文章..当我单击第一个URL ..一切都得到 正确显示..但是当我单击这三个链接中任何一个的第二个链接时,我都会收到错误消息..
异常详细信息:System.Xml.XmlException:根元素丢失.
源错误:
第70行:否则,如果(str =="Yahoo")
第71行: { this.RssDataSource1.Url ="http://eu.feeds.finance.yahoo.com/rss/2.0/category-us?region=UK&lang=en-GB";
第72行: this.ListView1.DataBind();
第73行: }
第74行:其他
我在第行发现错误. 72
这是堆栈跟踪:
[XmlException:根元素丢失.]
System.Xml.XmlTextReaderImpl.Throw(Exception e)+76
System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res)+61
System.Xml.XmlTextReaderImpl.ParseDocumentContent()+3979720
System.Xml.XmlTextReaderImpl.Read()+151
System.Xml.XmlLoader.LoadNode(布尔skipOverWhitespace)+58
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)+20
System.Xml.XmlLoader.Load(XmlDocument文档,XmlReader阅读器,布尔值saveWhitespace)+129
System.Xml.XmlDocument.Load(XmlReader阅读器)+108
System.Xml.XmlDocument.Load(字符串文件名)+87
C:\ Dev \ CodePlex \ Active \ ASPNETRSSToolkit \ v2 \ RssToolkit \ Rss \ DownloadManager.cs:204
中的RssToolkit.Rss.DownloadManager.DownLoadFeedDom(字符串url) C:\ Dev \ CodePlex \ Active \ ASPNETRSSToolkit \ v2 \ RssToolkit \ Rss \ DownloadManager.cs:176
中的RssToolkit.Rss.DownloadManager.GetFeedDom(字符串url) C:\ Dev \ CodePlex \ Active \ ASPNETRSSToolkit \ v2 \ RssToolkit \ Rss \ DownloadManager.cs:61
中的RssToolkit.Rss.DownloadManager.GetFeed(字符串url) C:\ Dev \ CodePlex \ Active \ ASPNETRSSToolkit \ v2 \ RssToolkit \ Rss \ RssDocumentBase.cs:117
中的RssToolkit.Rss.RssDocumentBase.Load(Uri url) C:\ Dev \ CodePlex \ Active \ ASPNETRSSToolkit \ v2 \ RssToolkit \ Web \ WebControls \ RssDataSource.cs:92
中的RssToolkit.Web.WebControls.RssDataSource.get_Rss() C:\ Dev \ CodePlex \ Active \ ASPNETRSSToolkit \ v2 \ RssToolkit \ Web \ Design \ RssDataSourceView.cs:64
中的RssToolkit.Web.Design.RssDataSourceView.ExecuteSelect(DataSourceSelectArguments参数) C:\ Dev \ CodePlex \ Active \ ASPNETRSSToolkit \ v2 \ RssToolkit \ Web \ Design \ RssDataSourceView.cs:52
中的RssToolkit.Web.Design.RssDataSourceView.Select(DataSourceSelectArguments参数,DataSourceViewSelectCallback回调) System.Web.UI.WebControls.DataBoundControl.PerformSelect()+142
System.Web.UI.WebControls.ListView.PerformSelect()+57
System.Web.UI.WebControls.BaseDataBoundControl.DataBind()+73
asia_news.TreeView2_SelectedNodeChanged1(Object sender,EventArgs e)在e:\ Study \ LAST SEM \ Project \ Backup \ Finance1 \ usa_news.aspx.cs:72
System.Web.UI.WebControls.TreeView.OnSelectedNodeChanged(EventArgs e)+111
System.Web.UI.WebControls.TreeView.RaisePostBackEvent(String eventArgument)+570
System.Web.UI.WebControls.TreeView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint)+1565
这是我后面的代码:
受保护的void TreeView2_SelectedNodeChanged1(对象发送者,EventArgs e)
{TreeNode项目= TreeView2.SelectedNode;
字符串str = item.Text.ToString();
this.ClientScript.RegisterStartupScript(typeof(Page),"test",< script> alert(str); return false;</script>"));
字符串old_str = this.RssDataSource1.Url.ToString();
如果(str ==""Google"")
{
this.RssDataSource1.Url ="http://feeds.reuters.com/reuters/USmarketsNews";
this.ListView1.DataBind();
}
否则,如果(str =="Yahoo")
{
this.RssDataSource1.Url ="http://eu.feeds.finance.yahoo.com/rss/2.0/category-us?region=UK&lang=en-GB";
this.ListView1.DataBind();
}
其他
{ this.RssDataSource1.Url ="http://www.ft.com/rss/world/us";
this.ListView1.DataBind();
}
this.ListView1.Visible = true;
}
}
Hi..I am using a RSS Datasource (provided by rsstoolkit of asp.net) to retrieve the list of latest newspaper articles and display them in a list view..I have three URL from which I am retrieving the articles..when I click on the first URL..everything gets displayed properly..but when I click on the second link of either of those three links I get an error..
Exception Details: System.Xml.XmlException: Root element is missing.
Source Error:
Line 70: else if (str == "Yahoo")
Line 71: { this.RssDataSource1.Url = "http://eu.feeds.finance.yahoo.com/rss/2.0/category-us?region=UK&lang=en-GB";
Line 72: this.ListView1.DataBind();
Line 73: }
Line 74: else
I am getting the error at line no. 72
Here is the stack trace:
[XmlException: Root element is missing.]
System.Xml.XmlTextReaderImpl.Throw(Exception e) +76
System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo(String res) +61
System.Xml.XmlTextReaderImpl.ParseDocumentContent() +3979720
System.Xml.XmlTextReaderImpl.Read() +151
System.Xml.XmlLoader.LoadNode(Boolean skipOverWhitespace) +58
System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) +20
System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace) +129
System.Xml.XmlDocument.Load(XmlReader reader) +108
System.Xml.XmlDocument.Load(String filename) +87
RssToolkit.Rss.DownloadManager.DownLoadFeedDom(String url) in C:\Dev\CodePlex\Active\ASPNETRSSToolkit\v2\RssToolkit\Rss\DownloadManager.cs:204
RssToolkit.Rss.DownloadManager.GetFeedDom(String url) in C:\Dev\CodePlex\Active\ASPNETRSSToolkit\v2\RssToolkit\Rss\DownloadManager.cs:176
RssToolkit.Rss.DownloadManager.GetFeed(String url) in C:\Dev\CodePlex\Active\ASPNETRSSToolkit\v2\RssToolkit\Rss\DownloadManager.cs:61
RssToolkit.Rss.RssDocumentBase.Load(Uri url) in C:\Dev\CodePlex\Active\ASPNETRSSToolkit\v2\RssToolkit\Rss\RssDocumentBase.cs:117
RssToolkit.Web.WebControls.RssDataSource.get_Rss() in C:\Dev\CodePlex\Active\ASPNETRSSToolkit\v2\RssToolkit\Web\WebControls\RssDataSource.cs:92
RssToolkit.Web.Design.RssDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) in C:\Dev\CodePlex\Active\ASPNETRSSToolkit\v2\RssToolkit\Web\Design\RssDataSourceView.cs:64
RssToolkit.Web.Design.RssDataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) in C:\Dev\CodePlex\Active\ASPNETRSSToolkit\v2\RssToolkit\Web\Design\RssDataSourceView.cs:52
System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
System.Web.UI.WebControls.ListView.PerformSelect() +57
System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
asia_news.TreeView2_SelectedNodeChanged1(Object sender, EventArgs e) in e:\Study\LAST SEM\Project\Backup\Finance1\usa_news.aspx.cs:72
System.Web.UI.WebControls.TreeView.OnSelectedNodeChanged(EventArgs e) +111
System.Web.UI.WebControls.TreeView.RaisePostBackEvent(String eventArgument) +570
System.Web.UI.WebControls.TreeView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
and here is my code behind:
protected void TreeView2_SelectedNodeChanged1(object sender, EventArgs e)
{TreeNode item = TreeView2.SelectedNode;
String str = item.Text.ToString();
this.ClientScript.RegisterStartupScript(typeof(Page), "test", "<script>alert(str);return false;</script>");
String old_str = this.RssDataSource1.Url.ToString();
if (str == "Google")
{
this.RssDataSource1.Url = "http://feeds.reuters.com/reuters/USmarketsNews";
this.ListView1.DataBind();
}
else if (str == "Yahoo")
{
this.RssDataSource1.Url = "http://eu.feeds.finance.yahoo.com/rss/2.0/category-us?region=UK&lang=en-GB";
this.ListView1.DataBind();
}
else
{ this.RssDataSource1.Url = "http://www.ft.com/rss/world/us";
this.ListView1.DataBind();
}
this.ListView1.Visible = true;
}
}
有什么主意吗?在此先感谢:)
any ideas guys? thanks in advance :)
推荐答案
感谢您的发帖.您所关心的更像是ASP.NET.我建议您在此论坛中提问. http://forums.asp.net
Thank you for posting. Your concern is more like ASP.NET. I suggest you ask it in this forum.http://forums.asp.net
最好的问候,
Larcolais
这篇关于System.Xml.XmlException:根元素丢失.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!