public bool CheckXmlAgainstGivenSchema(XmlHolder xmlHolder) { XDocument xmlDocument = XDocument.Parse(xmlHolder.XmlDocument); XmlSchemaSet xmlSchemaSet = new XmlSchemaSet(); xmlSchemaSet.Add("myNamespace", XmlReader.Create(new StringReader(xmlHolder.XmlSchema))); bool isValid = true; xmlDocument.Validate(xmlSchemaSet, (obj, eventArgs) => { isValid = false; }); return isValid; }
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.