load XML via a textreader using LINQ using StreamReader - CSharp XML

CSharp examples for XML:XML LINQ

Description

load XML via a textreader using LINQ using StreamReader

Demo Code


using System;/*w w w. j a v  a  2 s. com*/
using System.IO;
using System.Xml;
using System.Xml.Linq;

class MainClass
    {
        static void Main(string[] args)
        {

            string filename = @"ProductCatalog.xml";

            Console.WriteLine("Loading using a TextReader");
            TextReader reader = new StreamReader(filename);
            XElement root = XElement.Load(reader);
            // write out the xml
            Console.WriteLine(root);


        }
    }

Result


Related Tutorials