I'm trying to parse Rss2, Atom feeds using SyndicationFeed objects. But I'm getting XmlExceptions while parsing DateTime field like pubDate
2012-01-17 08:01:06
public static List<SyndicationItem> getRssData(string url)
{
List<SyndicationItem> list = new List<SyndicationItem>();
WebClient client = new WebClient();
try
{
SyndicationFeed feed = SyndicationFeed.Load(XmlReader.Create(url));
list = (from item in feed.Items select item).ToList();
}
catch (Exception e)
{
throw e;
}
return list;
}
The url link http://news.163.com/special/00011K6L/rss_newstop.xml
<item id="2">
<title>...</title>
<link>...</link>
<description>......</description>
<pubDate>2012-01-17 12:09:29</pubDate><-----Exception
</item>
Is there a better way to achieve this? Please help. Thanks.
list = feed.Items.ToList();
. Not part of the problem, but even so... (Likewise, please don't catch exceptions just to throw them again - and if you do want to catch and rethrow, just usethrow;
rather thanthrow e;
.)