To validate an XML file with an XSD file, use this !
public static XmlDocument ValidateAndLoadXmlDocument(string xmlFilePath, string xsdFilePath){
XmlDocument xmlDoc;XmlReaderSettings xmlSettings = new XmlReaderSettings();xmlSettings.Schemas.Add(null, xsdFilePath);xmlSettings.ValidationType = ValidationType.Schema;XmlReader xmlReader = XmlReader.Create(xmlFilePath, xmlSettings);xmlDoc = new XmlDocument();xmlDoc.Load(xmlReader);return xmlDoc;
}
Use this for asynchronous validation :
xmlSettings.ValidationEventHandler += new ValidationEventHandler(YourValidationEventHandler);
3e34e5be-af64-4f0f-a0ac-d5f6fc9aaedc|0|.0
XML, Web Services, .NET Projects
XML, Web Services, .NET Projects