Loading XML into a DataSet

XML can be loaded into a DataSet from a variety of sources, such as files or streams. Loading XML data from different sources often means using different method overloads in the DataSet. The specifics of loading XML data from a variety of sources are described in the following subsections.

Loading from a File

To load an XML file into a DataSet, use the DataSet.ReadXml(string) method and pass in the name of the file to load. For example:

C#
l_DataSet.ReadXml("\\MyDS.xml");

VB
l_DataSet.ReadXml("\MyDS.xml")

After the XML is loaded, the DataSet is populated as if the data had been entered programmatically. If the XML file does not describe a valid DataSet, then an exception is thrown. Typical scenarios that cause exceptions ...

Get Microsoft® .NET Compact Framework Kick Start 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.