I have a xml file in my local project - Data.xml with the following content
<TestApp>
<ManagerList>
<Manager>
<Name>Amit Rajkhowa</Name>
<EmpId>88378</EmpId>
</Manager>
<Manager>
<Name>Bijoy Gogoi</Name>
<EmpId>88506</EmpId>
</Manager>
</ManagerList>
</TestApp>
I used the following code in my code to pull the data from the xml.
DataSet dsStore = new DataSet();
DataTable dt= new DataTable();
dsStore.ReadXml("Data.xml");
dt= dsStore.Tables["Manager"];
string[] items = new string[dt.Rows.Count];
int i = 0;
foreach(DataRow dr in dt.Rows)
{
items.SetValue(dr["Name"].ToString(), i);
i++;
}
return items;
I found that the xml file is not found. Hence changed the path to the following:
dsStore.ReadXml(Server.MapPath("~/Data.xml"));