Mega Code Archive

 
Categories / C# / XML LINQ
 

XElement Save (TextWriter) serializes this element to a TextWriter

using System; using System.IO; using System.Linq; using System.Xml.Linq; using System.Collections; using System.Collections.Generic; public class MainClass{    public static void Main(){         XElement root = XElement.Parse(@"<Root> <Child> Text </Child> </Root>");         using (StringWriter sw = new StringWriter()) {             root.Save(sw);             Console.WriteLine(sw.ToString());         }    } }