This class is a fast writer used to output XML data to a stream or file. Two methods work with input from an XmlReader object to produce output from the currently positioned node. WriteAttributes() outputs all the node’s attributes. WriteNode() dumps the entire current node to the output stream and moves the XmlReader to the next node.

The remaining Write* methods of this class take string arguments that are output as properly formed XML markup. For example, WriteComment() takes a string and outputs it within <!-- ... --> markup. WriteStartAttribute() and WriteStartElement() provide some flexibility when writing elements and attributes. These two methods provide the opening contents of each type, given the name, prefix, and namespace. The next call can then provide the value of the element or attribute by other means. For example, you can use WriteString() for a simple string value, or another WriteStartElement() to begin a child element. WriteEndAttribute() and WriteEndElement() close the writing.

The derived XmlTextWriter class provides formatting functionality to the output data.

public abstract class XmlWriter {
// Protected Constructors
   protected method XmlWriter();  
// Public Instance Properties
   public abstract field WriteState WriteState{get; } 
   public abstract field string XmlLang{get; } 
   public abstract field XmlSpace XmlSpace{get; } 
// Public Instance Methods
   public abstract method void Close();  
   public abstract method void Flush(); public abstract method ...

Get C# in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.