public bool XmlValidate(string filePath) { bool isValid = true; try { XmlReader reader = new XmlTextReader(@"C:\Users\Priyanka\Downloads\XMLParserConsoleTester\XMLParserConsoleTester\XMLParsing_UTest\XMLJobSchema.xsd"); // Change in filepath as to where schema is stored in the user's PC XmlSchema myXmlSchema = XmlSchema.Read(reader, null); XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(filePath); XmlValidatorTestHelper xmlSchemaValidator = new XmlValidatorTestHelper(); xmlSchemaValidator.ValidXmlDoc(myXmlDocument, myXmlSchema); } catch (Exception e) { Console.WriteLine(e); isValid = false; } return(isValid); }
public bool XmlValidate(string filePath) { bool isValid = true; try { XmlReader reader = new XmlTextReader(@"C:\Users\z0045tam\source\repos\XMLParserConsoleApplicationFinal\XMLJobSchema.xsd"); XmlSchema myXmlSchema = XmlSchema.Read(reader, null); XmlDocument myXmlDocument = new XmlDocument(); myXmlDocument.Load(filePath); XmlValidatorTestHelper xmlSchemaValidator = new XmlValidatorTestHelper(); xmlSchemaValidator.ValidXmlDoc(myXmlDocument, myXmlSchema); } catch (Exception e) { Console.WriteLine(e); isValid = false; } return(isValid); }