Here i'm creating xml into file. it'll create by code and check availability of the file if exist it will delete old contain of the xml file and saves the new xml into this.
string createXMLpath = @"C:\\Temp\\myXMLfile.xml";
string xmlResult = xDocc.Descendants("RootResults").DescendantNodes().First().ToString();
if (!File.Exists(createXMLpath))
{
File.Create(createXMLpath).Close();
File.WriteAllText(createXMLpath, xmlResult);
}
else if (File.Exists(createXMLpath))
{
File.WriteAllText(createXMLpath, String.Empty);
using (StreamWriter sw = new StreamWriter(createXMLpath, true))
{
sw.WriteLine(xmlResult);
sw.Close();
}
}
ds.ReadXml(xmlResult);
GridView1.DataSource = ds;
GridView1.DataBind();