Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

XML Schema Validator

Posted on 2011-02-21
3
Medium Priority
?
1,298 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 2000 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

604 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