Hi Guys,
I have a block of code that validates an xml file against a schema:
This works great. However I've setup a namespace in the schema. When I am sent the xml file the namespace generated on the clients side is different. I need to change the namespace to the one I have in my schema. Please let me know how to do this.Code:Private Function ValidateXmlWithXsd(xmlUri As String, xsdUri As String) As String Dim strMessage As String = String.Empty Try Dim xmlSettings As New XmlReaderSettings() xmlSettings.Schemas = New System.Xml.Schema.XmlSchemaSet() xmlSettings.Schemas.Add("myschema", xsdUri) xmlSettings.ValidationType = ValidationType.Schema AddHandler xmlSettings.ValidationEventHandler, New ValidationEventHandler(AddressOf SettingsValidationEventHandler) Dim reader As XmlReader = XmlReader.Create(xmlUri, xmlSettings) While reader.Read() End While If nErrors > 0 Then Status = False strMessage = strErrorMsg Else Status = True strMessage = "Validation Passed" End If reader.Close() Return strMessage Catch ex As Exception Return False Finally End Try End Function


Reply With Quote
