Exceptions with DateTime parsing in RSS feed in C#

后端 未结 2 1623
名媛妹妹
名媛妹妹 2021-02-04 19:13

I\'m trying to parse Rss2, Atom feeds using SyndicationFeedFormatter and SyndicationFeed objects. But I\'m getting XmlExceptions while parsing DateTime field like pubDate and/or

2条回答
  •  抹茶落季
    2021-02-04 19:39

    to convert PublishDate in RSS to your computer datetime you could write this lines

      string dateStr = item.PublishDate.ToString("ffffd MMM dd HH:mm:ss zzzz yyyy");
                        DateTime PostDate = DateTime.ParseExact(dateStr, "ffffd MMM dd HH:mm:ss zzzz yyyy", CultureInfo.InvariantCulture);
    

提交回复
热议问题