Chapter 9. Working with XML Data

9.0. Introduction

ADO.NET and XML classes are tightly integrated in the .NET Framework. The DataSet can be filled with data or a schema from an XML stream or document. The DataSet can persist or serialize its data or schema to an XML stream or document. You can simultaneously work with the same data in a DataSet and with its XML representation. This chapter focuses on XML support in ADO.NET and in SQL Server.

The XML support in .NET is provided by classes in six namespaces:

System.Xml

Contains classes that provide standards-based support for processing XML.

System.Xml.Linq

Contains classes that provide support for LINQ to XML.

System.Xml.Schema

Contains classes that provide standards-based support for XML Schema Definition (XSD) language schemas.

System.Xml.Serialization

Contains classes that serialize objects into XML documents or streams.

System.Xml.XPath

Contains classes that parse and evaluate XPath.

System.Xml.Xsl

Contains classes that support Extensible Stylesheet Language (XSL) transformations.

.NET Framework classes support saving and loading both XML data and schema from and to ADO.NET disconnected classes. Recipe 9.1 shows how to load XML data into a DataSet or DataTable and how to save data in a DataSet or DataTable to an XML file. Recipe 9.2 shows how to load an XML schema into a DataSet and how to save the schema of a DataSet as an XML schema file. Recipe 9.3 shows how to customize the format of XML data saved from a DataSet.

The DiffGram is an XML ...

Get ADO.NET 3.5 Cookbook, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.