I'm trying to figure out why this site's RSS feed suddenly broke, and how I might go about fixing it.
This is the error information my company gave me to help fix it:
Error in line 17 position 39. An error was encountered when parsing a DateTime value in the XML.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Xml.XmlException: Error in line 17 position 39. An error was encountered when parsing a DateTime value in the XML.
Source Error:
Line 25: settings.DtdProcessing = DtdProcessing.Parse;
Line 26: XmlReader reader = XmlReader.Create(url, settings);
Line 27: SyndicationFeed feed = SyndicationFeed.Load(reader);
Line 28:
Line 29: foreach (SyndicationItem item in feed.Items.Take(NUMBEROFPOSTS)) {
Source File: ***\prosenstein-com\Models\NewsFeedModel.cs Line: 27
Stack Trace:
[XmlException: Error in line 17 position 39. An error was encountered when parsing a DateTime value in the XML.] System.ServiceModel.Syndication.Atom10FeedFormatter.DateFromString(String dateTimeString, XmlReader reader) +4372522
Below is what I believe to be the pertinent model code within the site's MVC framework.
private List<SyndicationItem> GetItemsFromUrl(string url) {
int NUMBEROFPOSTS = 6; // limits number of rss posts on page
List<SyndicationItem> postsList = new List<SyndicationItem>();
XmlReaderSettings settings = new XmlReaderSettings();
settings.DtdProcessing = DtdProcessing.Parse;
XmlReader reader = XmlReader.Create(url, settings);
SyndicationFeed feed = SyndicationFeed.Load(reader);
foreach (SyndicationItem item in feed.Items.Take(NUMBEROFPOSTS)) {
item.Id = item.Links[0].Uri.ToString();
postsList.Add(item);
}
reader.Close();
return postsList;
}
I'm pretty new to coding in MVC, and most of this code looks like Greek to me. If you could help me solve the problem, and also help me learn something in the process, I'd be most appreciative.