Solved

XML Schema Validator

Posted on 2011-02-21
3
1,294 Views
Last Modified: 2012-08-13
Hi Experts,

I've written an xml schema validator which works to a point.  I just need to try and get it a little more specific about the location of the error.  I have the schema file (.xsd) stored locally.

Is there anyway I can get the validator to give me specific line numbers in the xml file with the error?  Or at least the main element the error comes from?

txtresponse & txtxmlerror are both textboxes.

Any Help greatly appreciated.

I can provide both the schema and an xml file if required.

Thanks,
Private Sub btnvalxml_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnvalxml.Click
        txtResponse.Text = "No Errors"
        Dim myDocument As New XmlDocument
        myDocument.Load("S:\Training\MOJ_Add_Claims\AYA0004-0001\AYA0004-0001.xml")
        myDocument.Schemas.Add("", "d:\XMLSchema1.xsd")
        Dim eventHandler As ValidationEventHandler = New ValidationEventHandler(AddressOf ValidationEventHandler)
        myDocument.Validate(eventHandler)
    End Sub
    Private Sub ValidationEventHandler(ByVal sender As Object, ByVal e As ValidationEventArgs)
        Select Case e.Severity
            Case XmlSeverityType.Error
                Debug.WriteLine("Error: {0}", e.Message)
                txtxmlerror.Text = e.Message
                txtResponse.Text = "Errors Found"
            Case XmlSeverityType.Warning
                Debug.WriteLine("Warning {0}", e.Message)
                txtxmlerror.Text = e.Message
                txtResponse.Text = "Errors Found"
        End Select
    End Sub

Open in new window

0
Comment
Question by:jstlawyers
  • 2
3 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 500 total points
ID: 34944764
0
 

Author Comment

by:jstlawyers
ID: 34953815
Hi Kalpesh,

Thanks for your post, i've download the coding,

works great,

thanks,
0
 
LVL 16

Expert Comment

by:Kalpesh Chhatrala
ID: 34957795
if you satisfied with answer then

Please Accept my Post as Answer and Allot Points..
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question