Creates a new XmlWriter instance using the specified stream.
using System; using System.IO; using System.Xml; using System.Text; public class Sample { public static void Main() { XmlWriter writer = null; try { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = ("\t"); settings.OmitXmlDeclaration = true; writer = XmlWriter.Create("data.xml", settings); writer.WriteStartElement("book"); writer.WriteElementString("item", "tesing"); writer.WriteEndElement(); writer.Flush(); } finally { if (writer != null) writer.Close(); } } }