Create XmlReader from Stream : XmlReader « XML « C# / CSharp Tutorial






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);
    }
}








30.5.XmlReader
30.5.1.XmlReader: ReadElementContentAsString
30.5.2.Create XmlReader from Stream
30.5.3.Using XmlReader to read Xml result set from database
30.5.4.XmlReaderSettings and XmlWriterSettings
30.5.5.XmlTextReader in Action
30.5.6.Read Xml output from database
30.5.7.Chaining an XmlReader to an XmlWriter
30.5.8.extends XmlReader to wrap Sql statement
30.5.9.Create the validating reader