O'Reilly logo

C# in a Nutshell by Peter Drayton, Ted Neward, Ben Albahari

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required