示例#1
0
        private StudentXxe DeserializeStudent(string xml)
        {
            var        student    = new StudentXxe();
            TextReader textReader = new StringReader(xml);
            var        settings   = new XmlReaderSettings {
                DtdProcessing = DtdProcessing.Parse
            };
            var serializer = new XmlSerializer(typeof(StudentXxe));

            using (var xmlReader = XmlReader.Create(textReader, settings))
            {
                student = (StudentXxe)serializer.Deserialize(xmlReader);
            }

            return(student);
        }
示例#2
0
 public ActionResult UploadFile(HttpPostedFileBase file)
 {
     try
     {
         var student = new StudentXxe();
         if (file.ContentLength > 0)
         {
             string xmlText = new StreamReader(file.InputStream).ReadToEnd();
             student = DeserializeStudent(xmlText);
         }
         ViewBag.Message = "File Uploaded Successfully!!";
         return(View("Index", student));
     }
     catch (Exception ex)
     {
         ViewBag.Message = "File upload failed!!";
         return(View("Index"));
     }
 }
示例#3
0
        // GET: XmlExternalEntities
        public ActionResult Index()
        {
            var student = new StudentXxe();

            return(View(student));
        }