You will learn from this example how to read data from an XML file using vb.net and XML Schema. Source code:
Imports System
Imports System.Xml
Imports System.Xml.Schema
Imports System.IO
Imports System.Data
Public Class MainClass
Shared Sub Main()
Dim dsBooks As New DataSet()
dsBooks.ReadXmlSchema("books.xdr")
Console.WriteLine("Schema Data... ")
Dim dtBooks As DataTable
For Each dtBooks In dsBooks.Tables
Console.WriteLine("Table {0}, {1} Columns", _
dtBooks.TableName, dtBooks.Columns.Count)
Next
dsBooks.ReadXml("books.xml", XmlReadMode.IgnoreSchema)
Console.WriteLine("Data Loaded... ")
Console.WriteLine()
Dim drBook As DataRow
For Each drBook In dsBooks.Tables("Books").Rows
Console.WriteLine("{0} : {1} - ${2}", Book("Title"))
Next
End Sub
End Class
books.xdr
<?xml version = "1.0"?>
< Schema xmlns = "urn:schemas-microsoft-com:xml-data">
<ElementType name = "title" content = "textOnly"
model = "closed" />
<ElementType name = "book" content = "eltOnly" model = "closed">
<Element type = "title" minOccurs = "1" maxOccurs = "1" />
</ElementType>
<ElementType name = "books" content = "eltOnly" model = "closed">
<Element type = "book" minOccurs = "0" maxOccurs = "*" />
</ElementType>
</Schema>
XML File :Books.xml
<?xml version = "1.0"?>
<books xmlns = "x-schema:books.xdr">
<book>
<title>Introduction to vb.net </title>
</book>
<book>
<title>Introduction to Java </title>
</book>
<book>
<title>C# Beginners Guide </title>
</book>
<book>
<title>Introduction to Embedded software Programming </title>
</book>
<book>
<title>Ruby on Rails Tutorials </title>
</book>
</books>



