How to Include Records into XML Element C#

Mar 20 at 4:15 PM
Hi...I would like to please you guys to help me creating this xml file...I've tried with this code above but I've got some Errors...Using VS2013, C#

   XDocument docHeader = new XDocument( 
             new XElement("Report",
             new XElement("Versao", "1"),
             new XElement("Details", "")

        for (int i = 0; i < 2; i++)
           var docRecords =

            new XElement("Record", 

                           new XElement("ID", i.ToString()),

                           new XElement("Reference", "2017" + i.ToString() )



        using (var writer = new XmlTextWriter("C:\\Reports\\MyReport.xml", new UTF8Encoding(false)))