How to use SyndicationClient if the xml code has Invalid XML ? RRS feed

  • Question

  • Hi.. 

    I want to make an app to get news from a site and show them in a textbox.. And here is the code I've tried...

    SyndicationClient client = new SyndicationClient();
                Uri uri = new Uri(@"http://lankadeepa.lk/index.php/maincontroller/breakingnews_rss");
                    var feed = await client.RetrieveFeedAsync(uri);
                    foreach (SyndicationItem item in feed.Items)
                        string title = item.Title.Text;
                        textBox1.Text += title + Environment.NewLine + Environment.NewLine;

    Of course this code has no any wrong but the rss feed...

    And when I ran the program here is the error Ive got..


    An exception of type 'System.Exception' occurred in mscorlib.dll but was not handled in user code

    WinRT information: End tag 'admin:generatoragent' does not match the start tag 'channel'.

    Additional information: Invalid XML.

    End tag 'admin:generatoragent' does not match the start tag 'channel'.

    If there is a handler for this exception, the program may be safely continued.


    There is a problem with the xml code.. But I want to prevent that error and show the news titles in the textbox..

    Ive tried to do it with a try {} catch {} block.. But it ends up with showing nothing..

    Does the SyndicationClient class has someway to ignore errors like this and show the content from rss ?

    And please dont explain simply. Im new to C# and winrt app development !

    Thanks !

    Sunday, February 9, 2014 2:53 PM