I have a xml string and need to download the string to a .xml file. I am working on a asp.net web application. Following is my code.
   protected void btnDownloadXML_Click(object sender, EventArgs e)
    {
        try
        {
            string xmltext = divLogResults.InnerText;
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xmltext);
            doc.Save("myfilename.xml");
            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.ClearContent();
            response.Clear();
            response.ContentType = "text/xml";
            response.AddHeader("Content-Disposition", "attachment; filename=" + doc.Name + ";");
            response.Flush();
            response.End();
        }
        catch(Exception ex)
        {
            throw ex;
        }
    }
But I am only getting an empty xml text on download named #document.xml. What am I doing wrong.
