Reading and Writing XML




Data Using XmlReader and

XmlWriter

One of the major features of the .NET Framework is that it enables you to easily produce distributed
applications that are language-independent, and that are platform-independent when .NET is
ported to other platforms. XML plays a major part in this plan by acting as a simple, portable glue
layer that is used to pass data around in distributed applications. Microsoft has XML-enabled many
parts of the .NET Framework and it is crucial for the developers to get an understanding of how to
work with XML data using the .NET Framework classes. This chapter discusses the different ways
of reading and writing XML data utilizing the System.Xml classes. Specifically, this chapter covers:

  XML reading and writing support provided by the .NET Framework 2.0

  How to parse an XML file using the XmlReader class

  How to parse the attributes and data contained in the XML file

  How to customize the settings of the XmlReader object through the use of the reusable

XmlReaderSettings class

  How to write to an XML file using the XmlWriter class

  How to customize the output produced by the XmlWriter object using the

XmlWriterSettings class

  How to write namespaces using the XmlWriter class

  How to embed images in an XML document using the XmlWriter class

The following section starts by discussing the different XML reader and writer classes in the .NET
Framework 2.0.