O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

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

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 ...

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