Creates a new XmlWriter instance using the TextWriter and XmlWriterSettings objects.
using System;
using System.IO;
using System.Xml;
using System.Text;
public class Sample {
public static void Main() {
XmlWriterSettings settings = new XmlWriterSettings();
settings.OmitXmlDeclaration = true;
StringWriter sw = new StringWriter();
using (XmlWriter writer = XmlWriter.Create(sw, settings))
{
writer.WriteStartElement("book");
writer.WriteElementString("price", "1.9");
writer.WriteEndElement();
writer.Flush();
String output = sw.ToString();
}
}
}
Related examples in the same category