Reading RSS

Voorbeeld voor lezen van RSS feed:

WebRequest myRequest = WebRequest.Create(rssURL);

//// Heel belangrijk: Set een Timeout op je request
myRequest.Timeout= 15000;
Try
{
WebResponse myResponse = myRequest.GetResponse();

            Stream rssStream = myResponse.GetResponseStream();
            XmlDocument rssDoc = new XmlDocument();
            rssDoc.Load(rssStream);

            XmlNodeList rssItems = rssDoc.SelectNodes("rss/channel/item");

            string title = "";
            string link = "";
            string description = "";

            for (int i = 0; i < 2; i++)
            {
                XmlNode rssDetail;

                rssDetail = rssItems.Item(i).SelectSingleNode("title");
                if (rssDetail != null)
                {
                    title = rssDetail.InnerText;
                }
                else
                {
                    title = "";
                }

                rssDetail = rssItems.Item(i).SelectSingleNode("link");
                if (rssDetail != null)
                {
                    link = rssDetail.InnerText;
                }
                else
                {
                    link = "";
                }

                rssDetail = rssItems.Item(i).SelectSingleNode("description");
                if (rssDetail != null)
                {
                    description = rssDetail.InnerText;
                }
                else
                {
                    description = "";
                }

                Label L1 = new Label();
                L1.Text = "
";
                //Response.Write("
" + title + "
"); //Response.Write(description + ""); BWL3.Controls.Add(L1); //Control pnl = Page.FindControl("Panel2"); //pnl.Controls.Add(L1); } Catch ( Exception) { Label L1 = new Label(); L1.Text ="Connection to external resource failed......" pnl.Controls.Add(L1); }

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!