Mega Code Archive

 
Categories / C# / XML LINQ
 

XDocument Save (String, SaveOptions) serializes this XDocument to a file with option

using System; using System.IO; using System.Linq; using System.Xml.Linq; using System.Xml; using System.Collections; using System.Collections.Generic; public class MainClass {     public static void Main()     {         XDocument doc = new XDocument(             new XElement("Root",                 new XElement("Child", "content")             )         );         doc.Save("Root1.xml", SaveOptions.DisableFormatting);         Console.WriteLine(File.ReadAllText("Root1.xml"));         doc.Save("Root2.xml", SaveOptions.None);         Console.WriteLine(File.ReadAllText("Root2.xml"));     } }