XmlWriterSettings settings = new XmlWriterSettings(); settings.NewLineHandling = NewLineHandling.Entitize; XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fileStream, settings); writer.WriteStartElement("book"); writer.WriteStartAttribute("id"); writer.WriteString("123"); writer.WriteEndAttribute(); writer.WriteString("The Lord of the Rings"); writer.WriteEndElement();
XmlWriterSettings settings = new XmlWriterSettings(); settings.NewLineHandling = NewLineHandling.Entitize; XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(fileStream, settings); writer.WriteComment("This is a comment");This example writes an XML comment "This is a comment" to the output stream. These examples are using the System.Xml.XmlDictionaryWriter class in the System.Xml.dll package library.