I have an XSD file and an XML file, how can I check if the XML is in the right schema like the XSD file?
i know there is an validate function in the XmlDocumen
there is a much easy way to do it:
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;
}
}
P.S : I didn't wrote this in VS so there might be word that not in case sensitive, but this codes works!