XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8); writer.WriteStartElement("person"); writer.WriteAttributeString("name", "John"); writer.WriteEndAttribute(); // closes the "name" attribute writer.WriteEndElement();
XmlDictionaryWriter writer = XmlDictionaryWriter.CreateTextWriter(stream, Encoding.UTF8); writer.WriteStartElement("request"); writer.WriteAttributeString("requestId", "123"); writer.WriteEndAttribute(); // closes the "requestId" attribute writer.WriteEndElement();Package/library: System.Xml.