using System.Xml; XmlTextWriter writer = new XmlTextWriter(Console.Out); writer.WriteStartElement("message"); writer.WriteString("Hello, world!"); writer.WriteEndElement();
using System.Xml; XmlTextWriter writer = new XmlTextWriter(Console.Out); writer.WriteStartElement("person"); writer.WriteAttributeString("name", "John"); writer.WriteEndElement();In this example, the XmlTextWriter writes an XML element called "person", and then writes an attribute called "name" with the value "John". Package Library: The package library for System.Xml.XmlTextWriter is the .NET Framework, which is included with Microsoft Visual Studio. This means that you can use XmlTextWriter in any C# project that targets the .NET Framework, without needing to add any external dependencies.