I'm new to XML.
I have created an XML document that references an XSD doucment. How do I validate the XML document according to the rules defined in the XSD? I simply want to know if it complies...
Printable View
I'm new to XML.
I have created an XML document that references an XSD doucment. How do I validate the XML document according to the rules defined in the XSD? I simply want to know if it complies...
You'll most likely need to do it through code. What language are you programming in?
If you just want to check if the document is valid against a schema, you can use this online validator:
http://apps.gotdotnet.com/xmltools/xsdvalidator/
(ASP.NET/VB.NET CodeBehind)
VB6 ideally...
Hmm... I don't know how to do this in VB6, only in VB.NET.
But see if this link helps, it's got code later.
http://www.developerfusion.com/show/2386/
See my response in this thread.
Martin Liss
I have tried the code that you posted in your linked thread but I still have a problem.
When I run the following line of code:
I get the following error:VB Code:
oxmlSchema.Add "", strSchemaFile
I know my schema is valid because it validates here.Code:Incorrect definition for the root element in schema.
There is one difference I should mention, I had to define my schema object as: MSXML2.XMLSchemaCache30
This is because I get the following run time error when I attempt to instantiate an object of type: MSXML2.XMLSchemaCache40:
Any thoughts?Code:Unable to create ActiveX object
You need to be using MSXML4 which if you don't have you can download from MicroSoft. Once you add a reference to it in your project you can refer to MSXML2.XMLSchemaCache40.
Martin Liss
Thanks for your advice. I have downloaded MSXML4 (SP2).
Now it works fine! :)