Mega Code Archive

 
Categories / C# / XML
 

Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream

using System; using System.IO; using System.Xml; public class Sample {   public static void Main() {      XmlWriterSettings settings = new XmlWriterSettings();      settings.ConformanceLevel = ConformanceLevel.Fragment;      settings.Indent = true;      XmlWriter writer = XmlWriter.Create(Console.Out, settings);      writer.WriteStartElement("book");      writer.WriteElementString("title", "C#");      writer.WriteEndElement();      writer.Flush();      writer.WriteStartElement("cd");      writer.WriteElementString("title", "XML");      writer.WriteEndElement();      writer.Flush();        writer.Close();   } }