public static void XmlParserAds(Advertisement crtAd)//Receives a Advertisement instance and writes to its respective XML file { XDocument doc = XDocument.Load(xmlAds); XElement school = doc.Element("Ads"); school.Add(new XElement("Ad", new XElement("CompanyName", crtAd.CompanyName), new XElement("Price", crtAd.Price.ToString()), new XElement("Active", crtAd.GetStatus()), new XElement("AdBody", crtAd.AdBody), new XElement("CreationDate", crtAd.CreationDate), new XElement("ExpirationDate", crtAd.ExpirationDate.ToString()), new XElement("URL", crtAd.Url), new XElement("Image", crtAd.ImgPath) )); doc.Save(xmlAds); }