So you seen the following warning message?
Warning 1 'System.Xml.XmlValidatingReader' is obsolete: 'Use XmlReader created by XmlReader.Create() method using appropriate XmlReaderSettings instead. http://go.microsoft.com/fwlink/?linkid=14202' filename.cs 225 13 MonitoringFramework
private static bool isValidXML(string sXmlPath, string sXsdPath)
{
bool isValid = true;
XmlTextReader xReader = new XmlTextReader(sXmlPath);
XmlValidatingReader xValidator = new XmlValidatingReader(xReader);
xValidator.ValidationType = ValidationType.Schema;
xValidator.Schemas.Add(null, sXsdPath);
try
{
while (xValidator.Read()){}
}
catch (Exception e)
{
isValid = false;
}
return isValid;
}
The above code produces the following warning:

What is the solution? Below is my take on this problem
public static Boolean isValidXml(string sXmlPath, string sXsdPath)
{
bool isValid = true;
try
{
XmlReaderSettings settings = new XmlReaderSettings();
settings.Schemas.Add("", StringToXmlReader(sXsdPath));
settings.ValidationType = ValidationType.Schema;
XmlDocument document = new XmlDocument();
document.Load(sXmlPath);
XmlReader rdr = XmlReader.Create(new StringReader(document.InnerXml), settings);
while (rdr.Read()){}
}
catch
{
isValid = false;
}
return isValid;
}
private static XmlReader StringToXmlReader(string input)
{
return XmlReader.Create(new MemoryStream(Encoding.UTF8.GetBytes(input)));
}