コード例 #1
0
        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"));
            }
        }
コード例 #2
0
        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"));
                }
            }
        }