public void AddHostingUnit(HostingUnit hosting) { HostingUnitXML hostingUnit = hosting.ConvertToHostingUnitXML(); XElement area = new XElement("Area", hostingUnit.Area); XElement diary = new XElement("Diary"); foreach (var item in hostingUnit.Diary_XML) { diary.Add(new XElement("bool", item)); } XElement hostingunitname = new XElement("HostingUnitName", hostingUnit.HostingUnitName); XElement link = new XElement("ImageLink1", hostingUnit.ImageLink1); XElement link2 = new XElement("ImageLink2", hostingUnit.ImageLink2); XElement link3 = new XElement("ImageLink3", hostingUnit.ImageLink3); XElement jacuzzi = new XElement("Jacuzzi", hostingUnit.Jacuzzi); XElement key = new XElement("Key", hostingUnit.Key); XElement kitchen = new XElement("Kitchen", hostingUnit.Kitchen); XElement wifi = new XElement("WIFI", hostingUnit.WIFI); XElement pricepernight = new XElement("PricePerNight", hostingUnit.PricePerNight); XElement owner = new XElement("Owner", hostingUnit.Owner); XElement status = new XElement("Status", hostingUnit.Status); XElement swimmingpool = new XElement("SwimmingPool", hostingUnit.SwimmingPool); XElement tv = new XElement("TV", hostingUnit.TV); XElement HU = new XElement("HostingUnit", key, hostingunitname, area, link, link2, link3, jacuzzi, diary, kitchen, wifi, pricepernight, owner, status, swimmingpool, tv); HostingUnitRoot.Add(HU); HostingUnitRoot.Save(HostingUnitPath); }