hello........
Iam facing problem in XML....
I want to save employee records in XML file using user input....
But when i tried to save the data in XML File ...it is storing only one record ...
try to solve my problem so that i can add multiple records in the XML file..........
by one record i mean that..
i want to save employee details like employee no,employee name, salary and job....
when i tried to save the data.. it saves the record of only one employee...and it replaces the previous saved record ihv used following code to save the data
public void SaveData()
{
dtbl = new DataTable("emp");
dtbl.Columns.Add(new DataColumn("EmpNo",Type.GetType("System.String")));
dtbl.Columns.Add(new DataColumn("EmpName", Type.GetType("System.String")));
dtbl.Columns.Add(new DataColumn("EmpJob", Type.GetType("System.String")));
dtbl.Columns.Add(new DataColumn("EmpSalary", Type.GetType("System.String")));
//DataTable dt = display_data();
if (dtbl.Rows.Count > 0)
{
DataRow r = dtbl.NewRow();
r[0] = txtEmployeeNumber.Text;
r[1] = txtEmployeeName.Text;
r[2] = txtJob.Text;
r[3] = txtSalary.Text;
dtbl.Rows.Add(r);
str = Server.MapPath("XMLEmp.xml");
dtbl.WriteXml(str);
dtbl.AcceptChanges();
lblMsg.Text = "Data Saved";
}
SaveData() is the function which i hv called in btnSave_click
and str is varible of string datatype
now you can solve my problem easily...
Thanks.............