none
XML Reader / SyndicationFeed problem RRS feed

  • Question

  • I am trying to parse a specific RSS feed, and I have come across several places that describe starting like this:

                XmlReader reader = XmlReader.Create("http://www.foobar.com/clubs/4522/announcements.rss");
              
                SyndicationFeed feed = SyndicationFeed.Load(reader);

    I do this, and I get an error when attempting to put reader into SyndicationFeed.Load:

    Argument 1: Cannot convert from System.Xml.XmlReader to String

    This seems so simple and it is referenced everywhere, so why is it choking on this?   I am at a loss, and help would be appreciated


    DWM

    Tuesday, August 2, 2016 1:37 PM

Answers

  • OK - I figured it out, but it's rough. I would appreciate some experienced programmers providing feedback on how this can be better:

       

    publicclasstoaster


        {

    publicstaticasyncSystem.Threading.Tasks.Task<RssParser> ToastCreator()

            {

               

    varlocalSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

               

    varvDateTime = DateTime.Now;

               

    DateTimelastnewsitem = Convert.ToDateTime(localSettings.Values["lastnewsitem"]);        

                localSettings.Values[

    "lastnewsitem"] = Convert.ToString(vDateTime);     

               

    varhttp = WebRequest.Create("http://www.foo.com/clubs/4522/announcements.rss");

               

    varresponse = awaithttp.GetResponseAsync();

               

    varstream = response.GetResponseStream();

               

    StreamReaderreader = newStreamReader(stream);

               

    stringtext = reader.ReadToEnd();

               

    RssParserparser = newRssParser();

               

    varitems = parser.Parse(text);

               

    foreach(varItem initems)

                {

                   

    if(Item.PublishDate > lastnewsitem )

                   

    ToastHelper.CreateTextOnlyToast(Item.Summary, false);

                }

               

    return(parser);

            }

        }

    }


    DWM

    Tuesday, August 2, 2016 8:51 PM

All replies

  • OK - I figured it out, but it's rough. I would appreciate some experienced programmers providing feedback on how this can be better:

       

    publicclasstoaster


        {

    publicstaticasyncSystem.Threading.Tasks.Task<RssParser> ToastCreator()

            {

               

    varlocalSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

               

    varvDateTime = DateTime.Now;

               

    DateTimelastnewsitem = Convert.ToDateTime(localSettings.Values["lastnewsitem"]);        

                localSettings.Values[

    "lastnewsitem"] = Convert.ToString(vDateTime);     

               

    varhttp = WebRequest.Create("http://www.foo.com/clubs/4522/announcements.rss");

               

    varresponse = awaithttp.GetResponseAsync();

               

    varstream = response.GetResponseStream();

               

    StreamReaderreader = newStreamReader(stream);

               

    stringtext = reader.ReadToEnd();

               

    RssParserparser = newRssParser();

               

    varitems = parser.Parse(text);

               

    foreach(varItem initems)

                {

                   

    if(Item.PublishDate > lastnewsitem )

                   

    ToastHelper.CreateTextOnlyToast(Item.Summary, false);

                }

               

    return(parser);

            }

        }

    }


    DWM

    Tuesday, August 2, 2016 8:51 PM
  • Hi DWM,

    Welcome to the MSDN forum.

    I'm so glad to hear that your issue is solved and thank you for your sharing.

    BTW, if you think your reply is helpful, please mark it as answer, it will help other community members who have the same or similar issue to easier search this solution, thank you for your understanding.

    If you have any other .NET Framework Setup and Servicing issues, please feel free to let me know.

    Best regards,

    Sara


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.

    Wednesday, August 3, 2016 1:59 AM
    Moderator