Creating a DataSet from an XML File

Internally, a DataSet is represented by XML. This enables a DataSet to accurately mirror data returned by any data source. In fact, this is one of the reasons the DataSet object in ADO.NET is so much more powerful than the recordset object in ADO 2.7. Not only does the DataSet store data, but it also stores data about the schema that was used to store the data. Because DataSets are essentially XML entities, moving data from a DataSet to XML and from XML into a DataSet is a painless and straightforward process.

The DataSet object has an overloaded method named ReadXml() that enables you to read XML data from a string, stream, or file. The example in Listing 10.2 demonstrates how to transfer the data and the ...

Get Sams Teach Yourself ADO.NET in 24 Hours 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.