1
我正在開發一個Web服務來根據XSD文件驗證XML文件。我必須在另一個應用程序中使用此Web服務。該驗證XML的功能是:XML驗證Web服務
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;
}
當這個Web服務應用程序中使用,則返回「沒有錯誤」,所有輸入端,即使XML和模式文件不匹配。請幫我解決一下這個。