我尝试使用 SyndicationFeed 类,但它返回此错误
startIndex cannot be larger than length of string.
Parameter name: startIndex
当我尝试使用此代码访问发布日期时:
SyndicationFeed feed = SyndicationFeed.Load(XmlReader.Create("http://www.petra.gov.jo/library/RSS/RSS_Local.xml?ID=635551188249965540"));
foreach (SyndicationItem item in feed.Items)
{
HttpContext.Current.Response.Write(item.Title.Text + "///////" + item.PublishDate);
}
堆栈跟踪
[ArgumentOutOfRangeException: startIndex cannot be larger than length of string.
Parameter name: startIndex]
System.String.Substring(Int32 startIndex, Int32 length) +13911679
System.ServiceModel.Syndication.Rss20FeedFormatter.DateFromString(String dateTimeString, XmlReader reader) +311
System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItemFrom(XmlReader reader, SyndicationItem result, Uri feedBaseUri) +1756
[XmlException: Error in line 19 position 44. An error was encountered when parsing the item's XML. Refer to the inner exception for more details.]
System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItemFrom(XmlReader reader, SyndicationItem result, Uri feedBaseUri) +5071296
System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItem(XmlReader reader, SyndicationFeed feed) +199
System.ServiceModel.Syndication.Rss20FeedFormatter.ReadItems(XmlReader reader, SyndicationFeed feed, Boolean& areAllItemsRead) +181
System.ServiceModel.Syndication.Rss20FeedFormatter.ReadXml(XmlReader reader, SyndicationFeed result) +2820
System.ServiceModel.Syndication.Rss20FeedFormatter.ReadFrom(XmlReader reader) +209
System.ServiceModel.Syndication.SyndicationFeed.Load(XmlReader reader) +203
Class1.test() in c:\inetpub\wwwroot\Alordonia\App_Code\Class1.cs:16
_Default.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\Alordonia\Default.aspx.cs:12
System.Web.UI.Control.LoadRecursive() +71
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178