Name

XmlWriter

Synopsis

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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.