I am validating XML files on a server which has no internet access and
the validadation in C# does not work. Schema with which I am validating
has namespaces like: xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
xmlns:xenc="http://www.w3.org/2001/04/xmlenc#".
I have these schemas all locally on the disk, but it does not work. If
I try on a computer with internet access then it works just fine. Does
someone know what to do. Function with which I validate looks like
this:
private bool ValidXml(string XmlFile, string XSDLoc, string tns)
{
// . . .
string targetNamespaceURI = tns; // put the target namespace URI
of your schema here.
//XmlValidatingReader vr = new XmlValidatingReader( new
XmlTextReader( new StringReader( doc ) ) );
XmlValidatingReader vr = new XmlValidatingReader( new
XmlTextReader(XmlFile) );
vr.XmlResolver = new XmlUrlResolver();
MessageBox.Show(vr.NamespaceURI);
vr.Schemas.Add( targetNamespaceURI, XSDLoc);
vr.ValidationEventHandler += new ValidationEventHandler
(ValidationHandler);
vr.ValidationType = ValidationType.Schema;
_ValidationErrorsCount = 0;
_ValidationErrorsMsgs = "";
while(vr.Read());
vr.Close();
if (_ValidationErrorsCount > 0)
return false;
else
return true;
}
Thanks for any help ...