Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Help with checking xml format against its .xsd file

Posted on 2014-04-29
3
Medium Priority
?
223 Views
Last Modified: 2014-05-03
Hi,

How do you verify the xml file adheres to its schema using VB.NET?

Thanks,

Victor
0
Comment
Question by:vcharles
3 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 2000 total points
ID: 40031582
You would do something like:
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Dim settings As New XmlReaderSettings
        settings.ValidationType = ValidationType.Schema

        settings.Schemas.Add(XmlSchema.Read(New XmlTextReader("C:\temp\shiporder.xsd"), AddressOf ValidationHandler))

        Dim reader As XmlReader = XmlReader.Create("C:\temp\shiporder.xml", settings)

        Dim doc As New XmlDocument()
        doc.Load(reader)

    End Sub

    Private Sub ValidationHandler(sender As Object, e As ValidationEventArgs)
        MessageBox.Show(e.Message)
    End Sub

Open in new window

0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 40032010
Hi Victor;

You can also use Linq to check a XML document against a XSD file. See Microsoft documentation which also has an example at the bottom of the page. If you have any questions please ask.

XDocument.Validate Method
0
 

Author Closing Comment

by:vcharles
ID: 40039519
Thank You.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
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.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses

885 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