O'Reilly logo

C# 5.0 in a Nutshell, 5th Edition by Ben Albahari, Joseph 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 11. Other XML Technologies

The System.Xml namespace comprises the following namespaces and core classes:

System.Xml.*
XmlReader and XmlWriter

High-performance, forward-only cursors for reading or writing an XML stream

XmlDocument

Represents an XML document in a W3C-style DOM

System.Xml.XPath

Infrastructure and API (XPathNavigator) for XPath, a string-based language for querying XML

System.Xml.XmlSchema

Infrastructure and API for (W3C) XSD schemas

System.Xml.Xsl

Infrastructure and API (XslCompiledTransform) for performing (W3C) XSLT transformations of XML

System.Xml.Serialization

Supports the serialization of classes to and from XML (see Chapter 17)

System.Xml.XLinq

Modern, simplified, LINQ-centric version of XmlDocument (see Chapter 10)

W3C is an abbreviation for World Wide Web Consortium, where the XML standards are defined.

XmlConvert, the static class for parsing and formatting XML strings, is covered in Chapter 6.

XmlReader

XmlReader is a high-performance class for reading an XML stream in a low-level, forward-only manner.

Consider the following XML file:

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<customer id="123" status="archived">
  <firstname>Jim</firstname>
  <lastname>Bo</lastname>
</customer>

To instantiate an XmlReader, you call the static XmlReader.Create method, passing in a Stream, a TextReader, or a URI string. For example:

using (XmlReader reader = XmlReader.Create ("customer.xml"))
  ...

Note

Because XmlReader lets you read from potentially slow sources (Streams and URIs), ...

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