EDN Admin
Well-known member
Greetings:
Ive got the following code to compare an XML file agaisnt and schema:
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Public<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Shared<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Function<span style="font-size:x-small XmlAgainstSchema(<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small
byteArrayXml <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small (), _<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small byteArraySchema
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small (), _<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small schemaNameSpace
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small String<span style="font-size:x-small )
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small CheckResult<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Try
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using<span style="font-size:x-small memoryStreamXML =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small MemoryStream(byteArrayXml)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using<span style="font-size:x-small memoryStreamSchema =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small MemoryStream(byteArraySchema)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small schemaSet
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small XmlSchemaSet
schemaSet.Add(schemaNameSpace, XmlReader.Create(memoryStreamSchema))
<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small xmlReaderSettings
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small XmlReaderSettings
xmlReaderSettings.ValidationType = ValidationType.Schema
<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddHandler<span style="font-size:x-small xmlReaderSettings.ValidationEventHandler,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small ValidationEventHandler(<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddressOf<span style="font-size:x-small
ValidationHandler)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small readerXml
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small XmlReader = XmlReader.Create(memoryStreamXML, xmlReaderSettings)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small While<span style="font-size:x-small (readerXml.Read())<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small While
<span style="font-size:x-small
readerXml.Close()
<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small If<span style="font-size:x-small ErrorCount = 0
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Then
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Return<span style="font-size:x-small CheckResult.EXITO_COMPARACION<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Else
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Return<span style="font-size:x-small CheckResult.ERROR_COMPARACION<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small If
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Catch<span style="font-size:x-small ex
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small XmlSchemaException<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Return<span style="font-size:x-small CheckResult.ERROR_COMPARACION<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Catch<span style="font-size:x-small ex
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small Exception<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Throw<span style="font-size:x-small ex<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Try
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Function
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small But It doesnt seem Its working because even if I compare a random XML against my XSD the validation event
isnt called.
<span style="font-size:x-small <span style="color:#0000ff Please if you can asnwer me as soon as possible youll help me a lot.
<span style="font-size:x-small
<span style="font-size:x-small <span style="color:#0000ff Thanks for ur attention.
<span style="font-size:x-small
<span style="font-size:x-small <span style="color:#0000ff Best Regards
<span style="font-size:x-small
<span style="font-size:x-small <span style="color:#0000ff Ronald
View the full article
Ive got the following code to compare an XML file agaisnt and schema:
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Public<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Shared<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Function<span style="font-size:x-small XmlAgainstSchema(<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small
byteArrayXml <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small (), _<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small byteArraySchema
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Byte<span style="font-size:x-small (), _<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small ByVal<span style="font-size:x-small schemaNameSpace
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small String<span style="font-size:x-small )
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small CheckResult<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Try
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using<span style="font-size:x-small memoryStreamXML =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small MemoryStream(byteArrayXml)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using<span style="font-size:x-small memoryStreamSchema =
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small MemoryStream(byteArraySchema)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small schemaSet
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small XmlSchemaSet
schemaSet.Add(schemaNameSpace, XmlReader.Create(memoryStreamSchema))
<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small xmlReaderSettings
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small XmlReaderSettings
xmlReaderSettings.ValidationType = ValidationType.Schema
<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddHandler<span style="font-size:x-small xmlReaderSettings.ValidationEventHandler,
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small New<span style="font-size:x-small ValidationEventHandler(<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small AddressOf<span style="font-size:x-small
ValidationHandler)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Dim<span style="font-size:x-small readerXml
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small XmlReader = XmlReader.Create(memoryStreamXML, xmlReaderSettings)<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small While<span style="font-size:x-small (readerXml.Read())<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small While
<span style="font-size:x-small
readerXml.Close()
<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small If<span style="font-size:x-small ErrorCount = 0
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Then
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Return<span style="font-size:x-small CheckResult.EXITO_COMPARACION<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Else
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Return<span style="font-size:x-small CheckResult.ERROR_COMPARACION<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small If
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Using
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Catch<span style="font-size:x-small ex
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small XmlSchemaException<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Return<span style="font-size:x-small CheckResult.ERROR_COMPARACION<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Catch<span style="font-size:x-small ex
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small As<span style="font-size:x-small Exception<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Throw<span style="font-size:x-small ex<font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Try
<span style="font-size:x-small <font size="2
</font>
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small End<span style="font-size:x-small
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small Function
<span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small <span style="color:#0000ff; font-size:x-small But It doesnt seem Its working because even if I compare a random XML against my XSD the validation event
isnt called.
<span style="font-size:x-small <span style="color:#0000ff Please if you can asnwer me as soon as possible youll help me a lot.
<span style="font-size:x-small
<span style="font-size:x-small <span style="color:#0000ff Thanks for ur attention.
<span style="font-size:x-small
<span style="font-size:x-small <span style="color:#0000ff Best Regards
<span style="font-size:x-small
<span style="font-size:x-small <span style="color:#0000ff Ronald
View the full article