Extensible Markup Language (XML) is a markup laguage that defines a set of rules for encoding documents in a format that is both human readable and machine readable.
You can Make your own XML file and integrate with your Dataset or Datatable as per your Requirement. Here I am writing some steps, after follow this step you can integrate your XML file.
1. first create a test.xml file like this given code
<?xml version="1.0" encoding="utf-8" ?>
<HrSolution>
<HrEmployee>
<EmployeeID>123</EmployeeID>
<EmployeeName>Nirja</EmployeeName>
<EmployeeSalary>19000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>124</EmployeeID>
<EmployeeName>Priya</EmployeeName>
<EmployeeSalary>20000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>125</EmployeeID>
<EmployeeName>Deepika</EmployeeName>
<EmployeeSalary>12000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>126</EmployeeID>
<EmployeeName>Gayatri</EmployeeName>
<EmployeeSalary>22000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>127</EmployeeID>
<EmployeeName>Ramesh</EmployeeName>
<EmployeeSalary>18000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
</HrSolution>
2. Now add your gridview and on Button click write this code
DataSet ds = new DataSet();
//XML read by Dataset
ds.ReadXml(Request.MapPath("test.xml"));
//Show xml contents to the GridView
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
You can Make your own XML file and integrate with your Dataset or Datatable as per your Requirement. Here I am writing some steps, after follow this step you can integrate your XML file.
1. first create a test.xml file like this given code
<?xml version="1.0" encoding="utf-8" ?>
<HrSolution>
<HrEmployee>
<EmployeeID>123</EmployeeID>
<EmployeeName>Nirja</EmployeeName>
<EmployeeSalary>19000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>124</EmployeeID>
<EmployeeName>Priya</EmployeeName>
<EmployeeSalary>20000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>125</EmployeeID>
<EmployeeName>Deepika</EmployeeName>
<EmployeeSalary>12000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>126</EmployeeID>
<EmployeeName>Gayatri</EmployeeName>
<EmployeeSalary>22000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
<HrEmployee>
<EmployeeID>127</EmployeeID>
<EmployeeName>Ramesh</EmployeeName>
<EmployeeSalary>18000</EmployeeSalary>
<EmployeeAddress>Address</EmployeeAddress>
</HrEmployee>
</HrSolution>
2. Now add your gridview and on Button click write this code
DataSet ds = new DataSet();
//XML read by Dataset
ds.ReadXml(Request.MapPath("test.xml"));
//Show xml contents to the GridView
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
No comments:
Post a Comment