public ActionResult ExportXml(BLXMLItem[] items) { var obj = new BLXmlRoot { Items = items.Where(x => x.INCLUDE == "on").ToArray() }; using (var stringwriter = new System.IO.StringWriter()) { var serializer = new XmlSerializer(obj.GetType()); serializer.Serialize(stringwriter, obj); return(Content(stringwriter.ToString(), "application/xml")); } }
public ActionResult ExportXmlDownload(BLXMLItem[] items) { var obj = new BLXmlRoot { Items = items.Where(x => x.INCLUDE == "on").ToArray() }; using (var stringwriter = new StringWriter()) { var serializer = new XmlSerializer(obj.GetType()); using (var memoryStream = new MemoryStream()) { serializer.Serialize(memoryStream, obj); return(File(memoryStream.ToArray(), "application/xml", $"resume-{DateTime.Now:yyyy-MM-dd}.xml")); } } }