using System; using System.Xml; public class TestXMLWriter{ static void Main(string[] args) { XmlTextWriter writer = new XmlTextWriter("test.xml", new System.Text.ASCIIEncoding()); writer.Formatting = Formatting.Indented; writer.Indentation = 4; writer.WriteStartDocument(); writer.WriteComment("Comment"); writer.WriteStartElement("ElementName", "myns"); writer.WriteStartAttribute("prefix", "attrName", "myns"); writer.WriteEndAttribute(); writer.WriteElementString("ElementName", "myns", "value"); writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); writer.Close(); } }