load the XML using the file name using LINQ - CSharp XML

CSharp examples for XML:XML LINQ

Description

load the XML using the file name using LINQ

Demo Code


using System;/*from  www .  j  av a 2s .c om*/
using System.IO;
using System.Xml;
using System.Xml.Linq;

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

        string filename = @"ProductCatalog.xml";

        // load the XML using the file name
        Console.WriteLine("Loading using file name");
        XElement root = XElement.Load(filename);
        // write out the xml
        Console.WriteLine(root);
        Console.WriteLine("Press enter to continue");
        Console.ReadLine();


    }
}

Result


Related Tutorials