I have make a simple C# Program for you to
1) create a XML file from Dataset
2) To read the XMLSCHEMA to dataset.
// Place 2 Buttons and one Datagireview in your form :
DataTable dt;
private void fillRows(int pID, string pName, int pPrice)
{
DataRow dr;
dr = dt.NewRow();
dr["Product_ID"] = pID;
dr["Product_Name"] = pName;
dr["product_Price"] = pPrice;
dt.Rows.Add(dr);
}
private void button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
dt = new DataTable();
dt.Columns.Add(new DataColumn("Product_ID", Type.GetType("System.Int32")));
dt.Columns.Add(new DataColumn("Product_Name", Type.GetType("System.String")));
dt.Columns.Add(new DataColumn("product_Price", Type.GetType("System.Int32")));
fillRows(1, "product1", 1111);
fillRows(2, "product2", 2222);
fillRows(3, "product3", 3333);
fillRows(4, "product4", 4444);
ds.Tables.Add(dt);
ds.Tables[0].TableName = "product";
ds.WriteXml(@"D:\Product.xml");
MessageBox.Show("Done");
dataGridView1.DataSource = ds.Tables[0];
}
private void button2_Click(object sender, EventArgs e)
{
DataSet thisDataSet = new DataSet();
string filename = @"D:\Product.xml";
System.IO.FileStream stream = new System.IO.FileStream
(filename, System.IO.FileMode.Open);
System.Xml.XmlTextReader xmlReader =
new System.Xml.XmlTextReader(stream);
thisDataSet.ReadXmlSchema(xmlReader);
xmlReader.Close();
dataGridView1.DataSource = thisDataSet.Tables[0];
}