Reading XML and XML Schema into a DataSet
In addition to loading a DataSet from records in a database, you can also construct a DataSet and populate it using a defined XML Schema and content defined in an XML file. This allows you to load XML data and work with it as a DataSet. Here is an example Console application project that loads a DataSet from XML:
Imports System.Data.SqlClient Imports System.Data.Common Module Module1 Sub Main() Dim ds As DataSet = New DataSet() Try ds.ReadXmlSchema("Authors.xsd") ds.ReadXml("Authors.xml") Console.WriteLine(ds.GetXmlSchema()) Console.WriteLine(ds.GetXml()) Catch ex As SqlException Console.WriteLine(ex.Message) End Try End Sub End Module
Note
In order to read these files, they must be in the “bin” folder ...
Get Visual Basic® .NET by Example 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.