Click here to Skip to main content
Licence 
First Posted 6 Apr 2004
Views 44,058
Bookmarked 17 times

Project file which will validate for XML with XSD

By | 6 Apr 2004 | Article
Validating XML for the given XSD. Output is displayed in a textarea.

Introduction

In this project, you can select your XML file and corresponding XSD file. And you can do a validation.

Error on validation will be shown in the text area below the form. Here is the function which validates the XML:

Private Sub XMLvalidate_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles XMLvalidate.Click
        If Trim(txtXMLname.Text) = "" Or Trim(txtDTDname.Text) = "" Then
            MsgBox("Please select XML/XSD file", MsgBoxStyle.Information)
            Exit Sub
        End If
        Dim tr As XmlTextReader = New XmlTextReader(strXMLFileName)
        Dim sc As XmlSchemaCollection = New XmlSchemaCollection()
        Dim vr As XmlValidatingReader = New XmlValidatingReader(tr)
        Try
            txtMsg.Text = ""
            sc.Add(Nothing, strDTDFileName)
            vr.ValidationType = ValidationType.Schema
            vr.Schemas.Add(sc)
            AddHandler vr.ValidationEventHandler, AddressOf ValidationCallBack
            While (vr.Read())
            End While
            txtMsg.Text = txtMsg.Text & "Validation Success"
            txtMsg.Text = txtMsg.Text & vbCrLf
        Catch ee As Exception
            txtMsg.Text = ee.Message & ":" & ee.Source
        End Try
    End Sub

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Anil Gopalakrishnan

Team Leader

India India

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalgood application and test code PinmemberDonsw6:59 24 Aug '09  
GeneralValidating when the XML refuses to refence your XSD Pinmemberscott.leckie15:28 11 Jul '09  
Generalminoccurs validation PinmemberRHBKV18:22 21 Nov '07  
GeneralRe: minoccurs validation PinmemberAnil Gopalakrishnan17:56 22 Nov '07  
QuestionRe: minoccurs validation PinmemberRHBKV23:40 27 Nov '07  
GeneralNice app Pinmemberceejeeb5:15 14 Aug '07  
GeneralRe: Nice app PinmemberAnil Gopalakrishnan19:55 16 Aug '07  
GeneralNice little app... PinmemberEvan Stone7:31 22 Jul '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 7 Apr 2004
Article Copyright 2004 by Anil Gopalakrishnan
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid