Library tutorials & articles
XSD Schemas for VB Developers
- Why Schemas?
- Validating with Schema
- Authoring XSD Schemas
- Mapping VB Types to XSD
- Tighter Validation
- Schemas and Namespaces
- Summary
Validating with Schema
You’ll first instantiate an XMLSchema object and add to it the XSD schema file that you already have.
Dim schemaCache As MSXML2.XMLSchemaCache40
Set schemaCache = New MSXML2.XMLSchemaCache40
schemaCache.Add "","D:\schemas\mySchema.xsd"
When you call the Add method, the first parameter is the namespace that your XML document uses. If your XML document does not use a namespace, you can just pass an empty string like you see here (To learn more about XML namespaces, see the XML Namespaces tutorial.). The second parameter is the URL or file path pointing to the XSD schema document. Next, you create a DOM document and add to it the schemaCache:
Dim doc As MSXML2.DOMDocument40
Set doc = New MSXML2.DOMDocument40
Set doc.schemas = schemaCache
Now you are ready to load the XML document and do the validation:
doc.async = False
If Not doc.Load("D:\docs\myDoc.xml") Then
MsgBox "Error loading XML document: " &
doc.parseError.reason
End If
After loading the document, you must check the parseError property for validation errors. As you can see, validating is quite easy, once you have the XSD schema. Now I’ll show you the basics for creating XSD schemas.
Related articles
Related discussion
-
handling special character in xslt's
by bussureddy82 (1 replies)
-
Need help in parsing a big XML file with JAVA
by praveen_a_p (0 replies)
-
XML WITH JAVA
by suzan4love (3 replies)
-
A simple way to read an XML file in Java
by ayf (32 replies)
-
how to bind the XML data to the textboxes
by Slicksim (1 replies)
Related podcasts
-
Java Posse #202 - Newscast for Aug 22nd 2008
Newcast for August 22nd, 2008Fully formatted shownotes can always be found at http://javaposse.com Sadly, Java does not run on the Mars LanderThe Golden Gate Project http://research.sun.com/projects/goldengate/Space surveillance radar http://www.sun.com/aboutsun/pr/2008-04/sunflash Google has r...
Related jobs
-
Microsoft .Net Architect
in AMSTERDAM (€50K-€90K per annum) -
Trainer JAVA
in AMSTERDAM (€50K-€90K per annum) -
Applicatie ontwikkelaar binnen Defensie
in Amsterdam (£50K-£90K per annum) -
Ervaren SAP XI Specialist
in Amsterdam (€50K-€90K per annum)
This thread is for discussions of XSD Schemas for VB Developers.