Validate XML against a schema
private static string ValidateXML(string xsd, string strXml,string emailfrom,string emailto)
{
string ret = "";
string xsdfolder = ConfigurationManager.AppSettings["xsdfolder"];
xsd = "cr_caseinfo.xsd";
string schemaPath = xsdfolder + xsd;
try
{
XmlDocument xml = new XmlDocument();
xml.LoadXml(strXml);
xml.Schemas.Add(null, schemaPath);
xml.Validate(null);
}
catch (Exception ex)
{
Email.SendMail(emailfrom, emailto, "XML validation Error", ex.Source + "-" + ex.Message);
// throw new WebFaultException(HttpStatusCode.BadRequest);
ret = ex.Message;
}
return ret;
}