Processing XML Data with XmlReader and XmlWriter (Silverlight)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

The XML classes in the System.Xml namespace allow you to work with XML documents and data. These classes support parsing, writing, and editing XML data in memory. Note that the System.Xml namespace in the .NET Framework for Silverlight is a subset of the System.Xml in the .NET Framework. Most significantly, the XmlDocument type is not available in Silverlight. Instead, you should use the XmlReader class to read XML data. For information about other differences between the two frameworks, see Processing XML in the .NET Framework vs. the .NET Framework for Silverlight.

The XmlReader class provides non-cached, forward-only, read-only access to XML data. This class supports reading XML data from a stream, TextReader, or file in an application's XAP package. It defines methods and properties that allow you to move through XML data and read its content. You must use the Create method to create the XmlReader object.

The XmlWriter class provides a forward-only, write-only, non-cached way to generate XML streams. You must use the Create method to create the XmlWriter object. When you use the XmlWriter methods to output XML, the elements and attributes will not be completely written until you call the Close method or the Flush method.


In your Silverlight project, you must reference the .NET Framework assemblies that are installed with Silverlight, instead of those that are installed with Visual Studio.

In This Section