Пример #1
0
    protected void UploadButton_Click(object sender, EventArgs e)
    {
        var path = @"C:\Temp\Upload";

        if (FileUpload.HasFile)
        {
            var filename = FileUpload.FileName;

            path += filename;

            FileUpload.SaveAs(path);

            UploadStatusLabel.Text = "File saved as " + filename;

            var reader = new XmlReader();
            string orderXml = reader.Read(path);
            var parser = new OrderParser();
            var orderItems = parser.Parse(orderXml);

            GridView.DataSource = new List<Order>(orderItems);
            GridView.DataBind();
        }
        else
        {
            UploadStatusLabel.Text = "You did not specify a file to upload.";
        }
    }
Пример #2
0
        public void SetUp()
        {
            OrderParser = new OrderParser();

            XmlTest1 =
            "<orders>" +
                "<order>" +
                    "<customer>" +
                        "<title>Mr</title>" +
                        "<firstname>Canabrana</firstname>" +
                        "<lastname>Lammer</lastname>" +
                    "</customer>" +
                    "<orderitem>" +
                        "<id>26</id>" +
                        "<journal>Splinter Removal Weekly</journal>" +
                        "<start>2009-01-01</start>" +
                        "<currency>GBP</currency>" +
                    "</orderitem>" +
                "</order>" +
            "</orders>";
        }