public void LoadBadXMLFileWithSchema()
 {
     using (System.IO.StreamWriter xmlBadFile = new System.IO.StreamWriter(XmlFileNameBad))
     {
         xmlBadFile.WriteLine(XmlDocBad);
     }
     cXMLHandler handler = new cXMLHandler();
     string schema = handler.LoadSchemaFromFile(XsdFileName);
     string badDoc = handler.LoadXMLFileToString(XmlFileNameBad);
 }
 public void LoadGoodXMLFileWithSchema()
 {
     cXMLHandler handler = new cXMLHandler();
     string schema = handler.LoadSchemaFromFile(XsdFileName);
     string goodDoc = handler.LoadXMLFileToString(XmlFileNameGood);
     List<string> warnings = handler.GetWarnings();
     Assert.IsTrue(warnings.Count == 0);
 }
 public void LoadGoodXMLFileToString()
 {
     cXMLHandler handler = new cXMLHandler();
     string doc = handler.LoadXMLFileToString(XmlFileNameGood);
     Assert.AreEqual(doc.Trim(), XmlDocGood.Trim());
 }
        private void LoadFileButton_Click(object sender, EventArgs e)
        {
            // create an OpenFileDialog
            OpenFileDialog dialog = new OpenFileDialog();

            // set it's filter to only look at xml files
            dialog.Filter = "XML files (*.xml)|*.xml";

            // show it
            DialogResult dialogResult = dialog.ShowDialog();
            if (dialogResult != DialogResult.OK)
            {
                return;
            }

            // get the path from the dialog
            string filePath = dialog.FileName;

            // create a cXmlHandler
            cXMLHandler xmlHandler = new cXMLHandler();
            string xmlResult = "";

            // try to load the file
            try
            {
                xmlResult = xmlHandler.LoadXMLFileToString(filePath);
            }
            catch (System.Exception ex)
            {
                string exString = "Error: " + ex.Message;
                MessageBox.Show(exString);
                return;
            }

            MainTextBox.Clear();
            MainTextBox.Text = xmlResult;
        }