CSharp examples for System.Xml:XML Document
Get XDocument from file
using System.Xml.Linq; using System.Linq; using System.Reflection; using System.Security.Permissions; using System.IO;/*from ww w . j a v a2 s . c om*/ using System.Collections; using System.Xml; using System.Text; using System.Collections.Generic; using System; public class Main{ public static XDocument GetXDocument(string fileName) { XDocument document = new XDocument(); XmlTextReader reader = null; try { Stream resource = new FileStream(fileName, FileMode.Open); reader = new XmlTextReader(resource); document = XDocument.Load(resource); } catch (Exception exception) { // } finally { if (reader != null) { reader.Close(); } } return document; } }