Mega Code Archive

 
Categories / C# Tutorial / XML LINQ
 

Load xml from string, text file

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Xml.Linq; using System.IO; using System.Xml;     public class MainClass     {         public static void Main()         {             try             {                 XElement root = null;                 root = XElement.Load("file Name");                 //StreamReader reader = File.OpenText("fileName");                 //root = XElement.Load(reader);                 //XmlReader reader = XmlReader.Create("string");                 //root = XElement.Load(reader);                 //root = XElement.Parse("xml string");             }             catch (Exception ex)             {                 MessageBox.Show(ex.Message);             }         }     }