Save XDocument with XmlWriter in CSharp
Description
The following code shows how to save XDocument with XmlWriter.
Example
/*from ww w . j a v a 2 s. c o m*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Reflection;
using System.Xml;
using System.Xml.Linq;
class Program {
static void Main(string[] args) {
XmlReader reader = XmlReader.Create("Employee.xml");
XDocument xml = XDocument.Load(reader);
Console.WriteLine(xml);
StringWriter sw = new StringWriter();
XmlWriter w = XmlWriter.Create(sw);
xml.Save(w);
w.Close();
Console.WriteLine(sw.ToString());
}
}