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

Chapter 8. XML I/O

XML has, for better or worse, taken the programming industry by storm. It has become, in a matter of a few short years, the de facto standard for exchanging data between heterogeneous systems as well as the format of choice for storing just about any kind of data. The .NET runtime uses XML as part of its configuration, and the .NET Framework contains redesigned set of classes for accessing, consuming, producing, and transforming XML documents.

This chapter introduces the built-in support for XML, explains the relationships between XML and the I/O system in general, demonstrates the consumption and production of XML documents in both node-based and Infoset-based forms, highlights the use of XPath, and finally explores XSLT. All types within this namespace come from the System.Xml and System.Xml.XPath namespaces and are contained in the System.Xml.dll assembly. (When using these types, remember to reference the assembly either at the command line or from Visual Studio’s project dialogs.)

Accessing XML Documents

Like the I/O mechanism described in Chapter 10, the XML libraries in the .NET FCL follow a pattern of an “abstract base-class with concrete backing store implementation classes.” The two abstract base classes themselves are XmlReader and XmlWriter, used respectively for consuming and producing XML.

XmlReader

The XmlReader class, as its name implies, provides the ability to consume XML documents. It is an abstract base class, intended to be subclassed for working ...

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