using System;
using System.Data;
class Program
{
static DataTable Table()
{
DataTable table = new DataTable(
"Prescription");
table.Columns.Add(
"Dosage", typeof(int));
table.Columns.Add(
"Drug", typeof(string));
table.Columns.Add(
"Patient", typeof(string));
table.Columns.Add(
"Date", typeof(DateTime));
table.Rows.Add(25,
"Indocin",
"David", DateTime.Now);
table.Rows.Add(50,
"Enebrel",
"Sam", DateTime.Now);
table.Rows.Add(10,
"Hydralazine",
"Christoff", DateTime.Now);
table.Rows.Add(21,
"Combivent",
"Janet", DateTime.Now);
table.Rows.Add(100,
"Dilantin",
"Melanie", DateTime.Now);
return table;
}
static void Main()
{
// Create DataSet instance.
DataSet set = new DataSet(
"Hospital");
// Add new table.
set.Tables.Add(Table());
// Write xml schema data.
Console.WriteLine(set.GetXmlSchema());
}
}
<?xml version=
"1.0" encoding=
"utf-16"?>
<xs:schema id=
"Hospital" xmlns=
"" xmlns:xs=
"" xmlns:msdata=
"">
<xs:element name=
"Hospital" msdata:IsDataSet=
"true" msdata:UseCurrentLocale=
"true">
<xs:complexType>
<xs:choice minOccurs=
"0" maxOccurs=
"unbounded">
<xs:element name=
"Prescription">
<xs:complexType>
<xs:sequence>
<xs:element name=
"Dosage" type=
"xs:int" minOccurs=
"0" />
<xs:element name=
"Drug" type=
"xs:string" minOccurs=
"0" />
<xs:element name=
"Patient" type=
"xs:string" minOccurs=
"0" />
<xs:element name=
"Date" type=
"xs:dateTime" minOccurs=
"0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>