Here is quick and simple code sample where you can create and download-

public void CreateSitemap()
        {
             XDocument doc = new XDocument(
                new XElement("Root",
                    new XElement("Child", "content")
                )
            );
            doc.Save(AppDomain.CurrentDomain.BaseDirectory + "Downloaded.xml");

        }