Writes the node found at the current position of the specified System.Xml.XmlReader, and all sub-nodes.
- reader
- A System.Xml.XmlReader from which to copy the attributes.
- defattr
- A bool where true specifies to copy the default attributes from reader; otherwise, false.
Type Reason ArgumentNullException reader is null. InvalidOperationException The XmlWriter.WriteState is WriteState.Closed.
Operation
After the nodes are read, reader is moved to the next node at the same depth as the current node.If reader is in the ReadState.InitialXmlReader.ReadState, this method moves reader to the end of the stream. If reader is in the ReadState.EndOfFileXmlReader.ReadState, this method is non-operational.
Note to Inheritors
Override this method to customize the behavior of this method in types derived from the System.Xml.XmlWriter class.Usage
Use this method to write the node found at the current position and all sub-nodes.
The following example uses a System.Xml.XmlTextReader and a System.Xml.XmlTextWriter to copy an XML file, specified in the command line, to the console.
C# Example
using System; using System.Xml; public class Copier { public static void Main(string[] args) { XmlTextReader xtReader = new XmlTextReader(args[0]); XmlTextWriter xtWriter = new XmlTextWriter(Console.Out); xtWriter.WriteNode(xtReader, false); xtWriter.Close(); xtReader.Close(); } }
Namespace: System.Xml
Assembly: System.Xml (in System.Xml.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0