Save element to file with option in CSharp
Description
The following code shows how to save element to file with option.
Example
using System;/* ww w . ja va2 s. co m*/
using System.IO;
using System.Linq;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
public class MainClass
{
public static void Main()
{
string str;
XElement root = XElement.Parse(@"<Root> <Child> Text </Child> </Root>");
root.Save("Root.xml", SaveOptions.DisableFormatting);
str = File.ReadAllText("Root.xml");
Console.WriteLine(str);
root.Save("Root.xml", SaveOptions.None);
str = File.ReadAllText("Root.xml");
Console.WriteLine(str);
}
}