Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Visual Basic and XML

Status
Not open for further replies.

slok

Programmer
Jul 2, 1999
108
SG
I got the following error

==
Incorrect definition for root element in schema
==

when I try to validate an xml file using a schema(.xsd).

When I execute that code I get the above error at the "oxmlSchemaCache.Add" line. XSDDoc is
a global variable defined as an MSXML2.DOMDocument which I successfully read as xml in another part
of the program. The first part of the schema looks like the following. What is wrong?

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<xsd:schema xmlns:xsd=&quot; elementFormDefault=&quot;qualified&quot;>



' Code
Dim oxmlTempDoc As DOMDocument
Dim oxmlSchemaCache As XMLSchemaCache

Set oxmlTempDoc = New DOMDocument
Set oxmlSchemaCache = New XMLSchemaCache

ValidateXML = True

oxmlTempDoc.async = False
oxmlTempDoc.validateOnParse = False

oxmlSchemaCache.Add &quot;&quot;, XSDDoc
Set oxmlTempDoc.schemas = oxmlSchemaCache
oxmlTempDoc.Load gstrTempFileName

If oxmlTempDoc.parseError <> 0 Then
Err.Raise vbObjectError + 1, &quot;PO Validation&quot;, oxmlTempDoc.parseError.reason

ValidateXML = False
Exit Function
End If

Set oxmlTempDoc = Nothing
Set oxmlSchemaCache = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top