WebClient.OpenRead(String url) : WebClient « System.Net « C# / C Sharp by API






WebClient.OpenRead(String url)

  

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Xml;
using System.IO;

class MainClass
{
    static void Main(string[] args)
    {
        WebClient client = new WebClient();
        Stream rssFeedStream = client.OpenRead("http://yourRssFeedURL");

        XmlReader reader = XmlReader.Create(rssFeedStream);

        reader.MoveToContent();

        while (reader.ReadToFollowing("item"))
        {
            ProcessItem(reader.ReadSubtree());
        }
    }

    static void ProcessItem(XmlReader reader)
    {
        reader.ReadToFollowing("title");
        string title = reader.ReadElementContentAsString("title", reader.NamespaceURI);

        reader.ReadToFollowing("link");
        string link = reader.ReadElementContentAsString("link", reader.NamespaceURI);
        Console.WriteLine("{0}\n\t{1}", title, link);
    }
}

   
    
  








Related examples in the same category

1.WebClient.BaseAddress
2.WebClient.Credentials
3.WebClient.DownloadData
4.WebClient.DownloadFile
5.WebClient.DownloadString(Uri u)
6.WebClient.Headers
7.WebClient.OpenWrite
8.WebClient.ResponseHeaders
9.WebClient.UploadData
10.WebClient.UploadValues