load XML via a stream to the file using LINQ - CSharp XML

CSharp examples for XML:XML LINQ

Description

load XML via a stream to the file using LINQ

Demo Code


using System;/*  w  ww  .  ja v  a 2 s  .  c  o m*/
using System.IO;
using System.Xml;
using System.Xml.Linq;

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

            string filename = @"ProductCatalog.xml";

            // load via a stream to the file
            Console.WriteLine("Loading using a stream");
            FileStream filestream = File.OpenRead(filename);
            XElement root = XElement.Load(filestream);
            // write out the xml
            Console.WriteLine(root);


        }
    }

Result


Related Tutorials