I've inherited some xml that doesn't have a namespace and doesn't have a
reference to the schema. The schema doesn't have a targetNamespace attribute.
I'm trying to build a test tool, in C#, which will send the xml to the server
and then validate the response against the schema. When I try and do this I
get a "The attribute targetNamespace does not match the designated namespace
URI" error.
Here's a snippet of the validation code:
XmlParserContext context = new XmlParserContext(null, null, "",
XmlSpace.None);
XmlValidatingReader vr = new XmlValidatingReader(strXmlMessage,
XmlNodeType.Element, context);
XmlSchemaCollection mySchema = new XmlSchemaCollection();
mySchema.Add("urn:sdkgw-schema", "SDKGW.xsd");
vr.ValidationType = ValidationType.Schema;
vr.Schemas.Add(mySchema);
XmlDocument doc = new XmlDocument();
doc.Load(vr);
The first question is can I validate an xml string against a schema that it
doesn't refer to and that doesn't use namespaces? If the answer to that is
yes then can anyone see what I'm doing wrong in my validation code?
thanks, Ian