Creating the XmlTextWriter


Creating the XmlTextWriter

To create the XmlTextWriter , we need to give it a stream to write to. XmlTextWriter(string filename, Encoding encoding) is the simplest constructor to use. You pass in the fully qualified name of the file to write to and the encoding to write the XML text with. The code in Listing 10.20 demonstrates how to create an XmlTextWriter .

Listing 10.20
 C# XmlTextWriter writer = new XmlTextWriter("output.xml", Encoding.UTF8); VB Dim writer As New XmlTextWriter("output.xml", Encoding.UTF8); 

Listing 10.20 creates an XmlTextWriter that will write to the file output.xml in the root directory of a Windows CE device by using UTF-8 character encoding.

The same filename restrictions that apply to loading an XmlTextReader apply to the XmlTextWriter . The fully qualified name of the file should be used to specify the output file.



Microsoft.NET Compact Framework Kick Start
Microsoft .NET Compact Framework Kick Start
ISBN: 0672325705
EAN: 2147483647
Year: 2003
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net