xml validation using msxml and schema

C

cyberleo80

hi...
as in object...
i tring to validate an xml doc at runtime with this code:

set objXMLSchema = Server.CreateObject ("Msxml2.DOMDocument.4.0")
objXMLSchema.async = false
objXMLSchema.validateOnParse = true
objXMLSchema.load Server.MapPath(".") & "schemas\Schema.xsd"

set objXMLSchemaCache =
Server.CreateObject("Msxml2.XMLSchemaCache.4.0")
objXMLSchemaCache.add "", objXMLSchema

objXMLDocument.async = false
objXMLDocument.validateOnParse = true

set objXMLDocument.schemas = objXMLSchemaCache

objXMLDocument.load( Request )

set myerr = objXMLDocument.validate()
but the validity is not verified....
can somebody help me?
 
M

Martin Honnen

i tring to validate an xml doc at runtime with this code:

set objXMLSchema = Server.CreateObject ("Msxml2.DOMDocument.4.0")
objXMLSchema.async = false
objXMLSchema.validateOnParse = true
objXMLSchema.load Server.MapPath(".") & "schemas\Schema.xsd"

set objXMLSchemaCache =
Server.CreateObject("Msxml2.XMLSchemaCache.4.0")
objXMLSchemaCache.add "", objXMLSchema

objXMLDocument.async = false
objXMLDocument.validateOnParse = true

set objXMLDocument.schemas = objXMLSchemaCache

objXMLDocument.load( Request )

Check the return value of the load method e.g.
Dim Valid
Valid = objXMLDocument.load(Request)
If Valid Then
...
Else
check objXMLDocument.parseError.reason
 
C

cyberleo80

Martin said:
Check the return value of the load method e.g.
Dim Valid
Valid = objXMLDocument.load(Request)
If Valid Then
...
Else
check objXMLDocument.parseError.reason


thanks...
your hint is valid...

but the correct code is:

set objXMLDocument = Server.CreateObject ("Msxml2.DOMDocument.4.0") '
lista in arrivo
objXMLDocument.async = false
objXMLDocument.validateOnParse = true

set objXMLSchemaCache = Server.CreateObject
("Msxml2.XMLSchemaCache.4.0") ' cache
objXMLSchemaCache.add "", Server.MapPath(".") & "\schemas\Schema.xsd"

set objXMLDocument.schemas = objXMLSchemaCache

Dim valid
valid = objXMLDocument.load(Request)

if( not valid ) then
'insert error management here
end if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top