Beispiel #1
0
        public DynamicXMLVM StreamToDynamicXMLVM(Stream xmlFile)
        {
            var result = new DynamicXMLVM();

            XmlReaderSettings settings = new XmlReaderSettings();

            settings.DtdProcessing = DtdProcessing.Parse;
            XmlReader reader = XmlReader.Create(xmlFile, settings);

            while (reader.Read())
            {
                var val = new ValueInValue();

                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    val.Name = reader.Name;
                    break;

                case XmlNodeType.Text:
                    val.Value = reader.Value;
                    break;
                }

                //var currenType = reader.NodeType;
                //if (currenType == XmlNodeType.Element)
                //    val.Name = reader.Name;
                //if (currenType == XmlNodeType.Text)
                //    val.Value = reader.Value;
                //if(val.Name != null && val.Value != null)
                //    result.Values.Add(val);
            }

            return(result);
        }
Beispiel #2
0
        public IActionResult OpenFile([FromForm] IFormFile fileInput)
        {
            var result = new DynamicXMLVM();

            if (fileInput != null)
            {
                // Check if XML
                if (fileInput.ContentType == "text/xml")
                {
                    using (var reader = new StreamReader(fileInput.OpenReadStream()))
                    {
                        result = StreamToDynamicXMLVM(reader.BaseStream);
                    }
                }
            }


            return(RedirectToAction(nameof(Index), new { vm = result }));
        }
Beispiel #3
0
 public IActionResult Index(DynamicXMLVM vm)
 {
     return(View(vm));
 }