Hi Anish,
Try the below code which may be helpful for u . :)
string XMLName = FilePath + "Code_Proj.xml";
using (FileStream fs = new FileStream(XMLName, FileMode.OpenOrCreate, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(fs))
{
sw.Write("<?xml version='1.0' encoding='UTF-8'?> \n" +
"<stocklevel>\n ");
DataView dv = new DataView(ds.Tables[0]);
System.Data.DataTable dt = dv.ToTable(true, "Barcode");
foreach (DataRow drv in dt.Rows)
{
string Barcode = drv["Barcode"].ToString();
DataRow[] drs = ds.Tables[0].Select("Barcode = '" + Barcode + "'");
sw.Write("<barcode>" + Barcode + "\n");
sw.Write("</barcode>\n");
foreach (DataRow drData in drs)
{
string Storecode = drData["storecode"].ToString();
string LastUpdatedDate = drData["lastupdated"].ToString();
string Level = drData["stocklevel"].ToString();
sw.Write("<stocklevel storecode='" + Storecode + "' lastupdated='" + LastUpdatedDate + "' " + Level + " /> \n");
}
}
sw.Write("</stocklevel>\n");
fs.Flush();
}
}
GC.Collect();