Friday, 3 December 2010

Using Data from XML file within project

I have a xml file in my local project - Data.xml with the following content
         <Name>Amit Rajkhowa</Name>
        <Name>Bijoy Gogoi</Name>


I used the following code in my code to pull the data from the xml.

DataSet dsStore = new DataSet();

DataTable dt=  new DataTable();
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);

return items;

I found that the xml file is not found. Hence changed the path to the following: