0

I'm developing simple C# application which will present rss feeds. I have problem reading rss feeds from some web pages. The problem comes when parsing pubDate: Error in line 1 position 829. An error was encountered when parsing a DateTime value in the XML.

        XmlReader reader = XmlReader.Create("http://vest.com.mk/rssGenerator/");
        SyndicationFeed feed = SyndicationFeed.Load(reader);

        foreach (var item in feed.Items)
        {
            Console.WriteLine(item.Title.Text);
            Console.WriteLine(item.Id.ToString());
            Console.WriteLine(item.PublishDate.ToString("dd/MM/yyyy"));
            Console.WriteLine();
        }
Mega
  • 557
  • 2
  • 10
  • 22

2 Answers2

1

You could do these things to get more information,

  • Post the exception message to your problem description.
  • Add a try catch around the code, and log the urls that fail.
  • If there are any failing urls, try visit them looking for any 404s or anything out of the ordinary.
swallentin
  • 211
  • 2
  • 6
0

By looking at the code you pasted and the fact that your calling a bunch of feeds, my guess is that the PublishDate property might be null or returning a date format that can't be parsed.

Try checking for a null value on the DateFormat property.

swallentin
  • 211
  • 2
  • 6
  • I tried to remove `Console.WriteLine(item.PublishDate.ToString("dd/MM/yyyy"));` but I got the same error. The error comes in this line `SyndicationFeed feed = SyndicationFeed.Load(reader);` – Mega Dec 05 '12 at 23:48