/* * Created by vincent.tollu@gmail.com * IDE: SharpDevelop * Distributed under the GPL */ using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Text; public class MyClass { public static void Main() { MemoryStream streamXML = new MemoryStream(); System.Xml.XmlTextWriter xw = new System.Xml.XmlTextWriter(streamXML, null); xw.Formatting = System.Xml.Formatting.Indented; xw.Indentation = 2; xw.WriteStartDocument(); xw.WriteStartElement("Main"); xw.WriteElementString("node1","text"); xw.WriteStartElement("node2"); xw.WriteAttributeString("param1", "foo"); xw.WriteAttributeString("param2", "bar"); xw.WriteAttributeString("param3", "baz"); xw.WriteEndElement(); xw.WriteEndElement(); xw.WriteEndDocument(); xw.Flush(); byte[] buffer = streamXML.ToArray(); xw.Close(); streamXML = new MemoryStream(buffer); ASCIIEncoding enc = new ASCIIEncoding(); string toto = enc.GetString(buffer); System.Console.WriteLine(toto); System.Console.ReadLine(); XmlDocument doc = new XmlDocument(); doc.Load("Q317666.xml"); xw.WriteDocType("toto", null, "toto.dtd", null); xw.Flush(); buffer = streamXML.ToArray(); xw.Close(); streamXML = new MemoryStream(buffer); toto = enc.GetString(buffer); System.Console.WriteLine(toto); System.Console.ReadLine(); } }