Read and Write XML in asp.net C#
Read and Write XML in asp.net C#
//Create
a datatable to store XML data
DataTable DT = new DataTable();
DT.Columns.Add("FirstName");
DT.Columns.Add("LastName");
DT.Columns.Add("Gender");
DT.Columns.Add("Age");
DT.Rows.Add(new object[] { "Sam", "deol", "male", 20 });
DT.Rows.Add(new object[] { "kandy", "deol", "male", 20 });
//Create
a dataset
DataSet DS = new DataSet();
//Add
datatable to this dataset
DS.Tables.Add(DT);
//Write
dataset to XML file
DS.WriteXml(Server.MapPath("~/test.xml"));
DataSet ds1 = new DataSet();
ds1.ReadXml(Server.MapPath("~/test.xml"));
DataTable dt1 = ds1.Tables[0];
Comments
Post a Comment