I am developing a web service to validate an XML file against XSD file. I have to use this web service in another application. The function that validates XML is:
public string validate(String xml_file, string xsd_file)
{
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(null, xsd_file);
XDocument custOrdDoc = XDocument.Load(xml_file);
string error_msg = "no error";
custOrdDoc.Validate(schemas, (o, e) =>
{
error_msg = e.Message;
});
return error_msg;
}
When this web service is used in an application, it returns "no error" for all inputs, even if the xml and schema files do not match. Please help me with this.