How Do I...Load a DataSet with XML?

This sample illustrates how to load a DataSet with XML Data. The sample builds on the topic, How Do I...Create DataSet mappings from an XSD schema?, by first loading XML data into an XmlDataDocument and then accessing this data from the DataSet. The DataSet has previously loaded a schema in order to create the internal mappings. This sample in effect shows the transition between XML data and the creation of relational objects to access that XML data.

VB LoadDataSetXMLData.aspx

As shown in the following code, this sample implements the ParseSchema function to load the XML Schema Definition
language (XSD) schema, books.xsd, into the DataSet property on the XmlDataDocument. Then, the sample uses the Load method of the XmlDataDocument to load the XML file, books.xml.

As in How Do I...Create DataSet Mappings from an XSD schema?, the DisplayTableStructure method (built with the books.xsd schema file) enables the sample to display the internal table structure by simply iterating over the collections of Tables, Columns, and Rows, and then formatting the output. This sample extends this concept with the DisplayTables method (shown in the following code) which enables the sample to display the contents of the XML file. This sample uses the For Each keyword instead of a For loop to illustrate an alternative mechanism for iterating over the collections.