Solved

XML Schema Validator

Posted on 2011-02-21
3
1,295 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

688 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