aha*_*ron 23
有一个很简单的方法:
private void ValidationCallBack(object sender, ValidationEventArgs e)
{
throw new Exception();
}
public bool validate(string sxml)
{
try
{
XmlDocument xmld=new XmlDocument ();
xmld.LoadXml(sxml);
xmld.Schemas.Add(null,@"c:\the file location");
xmld.validate(ValidationCallBack);
return true;
}
catch
{
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
PS:我没有在VS中写这个,所以可能有一些不区分大小写的字,但这个代码有效!