I am trying to perform a validation of XML files using XSD Schema's. However when I perform the validation it instantly skips right through the line of code without performing any validation. The XML files I am running this against are large (20 MB and larger), so I know it should take a while. I am new to trying this, so it is possible that I am way off mark. If I am please let me know.
I am trying to utilize a schema that is offline, rather than the one detailed in the XML file. I don't know if this is part of my problem.
XML header code
Here is the c# code performing the validation
I greatly appreciate any help you can give.
Thanks.
Patrick
I am trying to utilize a schema that is offline, rather than the one detailed in the XML file. I don't know if this is part of my problem.
XML header code
Code:
<?xml version="1.0" encoding="utf-8" ?>
- <TRAINING_COURSE_COMPLETE xmlns:xsi="[URL unfurl="true"]http://www.w3.org/2001/XMLSchema-instance"[/URL] xmlns="urn:com.website.tech.lms.course_complete" xsi:schemaLocation="urn:com.website.tech.lms.course_complete course_complete.xsd">
Here is the c# code performing the validation
Code:
private void btnValidate_Click(object sender, System.EventArgs e)
{
string xmlPath = "C:\\Inetpub\\[URL unfurl="true"]wwwroot\\XMLExport\\trng_cse_cmpl.XML";[/URL]
XmlTextReader Xmlrd = new XmlTextReader(xmlPath);
XmlValidatingReader Xmlvr = new XmlValidatingReader(Xmlrd);
Xmlvr.ValidationType=ValidationType.Schema;
XmlSchemaCollection cache = new XmlSchemaCollection();
string xsdPath = "C:\\Inetpub\\[URL unfurl="true"]wwwroot\\XMLExport\\Course_complete.XSD";[/URL]
cache.Add("urn:com.website.tech.lms.course_complete", xsdPath);
Xmlvr.Schemas.Add(cache);
Xmlvr.ValidationEventHandler +=new ValidationEventHandler(XmlValidationEventHandler);
try
{
Xmlvr.Read();
}
catch
{
txtMessage.Text = "Error";
}
finally
{
Xmlvr.Close();
}
txtMessage.Text = "Done Validating".ToString();
}
private void XmlValidationEventHandler(object sender, ValidationEventArgs e)
{
txtMessage.Text = e.Message.ToString();
}
I greatly appreciate any help you can give.
Thanks.
Patrick