Click here to Skip to main content
15,879,474 members
Articles / Programming Languages / XML
Article

Simple and Cool XML Validator

Rate me:
Please Sign up or sign in to vote.
2.55/5 (7 votes)
27 Sep 2007CPOL2 min read 33.9K   1K   21   4
A small program you can use to validate an XML document against a schema

Background

I woke up one morning and decided to read about XML. In the video tutorial that I was watching on my computer, the instructor used a self made XML Validator to test the XML and XSD documents he created. I searched the whole DVD-ROM for the Validator, but… it wasn't there. So, I decided to write one that I could use, and also put it up for public use here on The Code Project. Here is the result (it took me half a day to get it to work).

Introduction

This small program will help you validate your XML document/database/... against your laid down specification (schema). The interface is so simple that you'll understand what to do and how to use it once you see it. I didn't do any digging into the source code, because it's mostly Microsoft's code - I only implemented it.

It's very easy to operate the machine; it looks like this:

Screenshot - image001.png

Load the XML schema file by clicking the button next to the XML Schema File textbox; it displays an open file dialog. Browse the folders for your schema file and click open.

In the textbox below, a message appears telling you if your schema file was valid or not. If you had a valid schema file, you might want to validate an XML document against it. The button next to the XML document textbox will open an open file dialog box for you to select your XML document. The moment you load the document, it gets checked if it’s a valid XML document. By this time, the validate button will have been activated. Click this button to validate the XML document against the schema file you specified. If the document conforms to the schema, you'll get a “Document validation against Schema was successful” message. Below is a sample output:

Screenshot - image003.png

The code is rather shabby, but it's easy to understand. If you have a question about the code, please feel free to ask.

History

  • 27th September, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer TEDATA
Nigeria Nigeria
Seun (Laolusrael) loves programming. I learnt 80% of what I know in programming all alone. I use my God-given mind to do a lot of thinking, and...
Currently Seun is a student studying software engineering, and working freelance.

Comments and Discussions

 
GeneralEnhancement.... Pin
Anurag Gandhi27-Sep-07 19:04
professionalAnurag Gandhi27-Sep-07 19:04 
GeneralRe: Enhancement.... Pin
Seun28-Sep-07 4:38
professionalSeun28-Sep-07 4:38 
GeneralRe: Enhancement.... Pin
Bharat Mallapur6-Jan-09 19:16
Bharat Mallapur6-Jan-09 19:16 
GeneralRe: Enhancement.... Pin
Seun16-Jan-09 12:03
professionalSeun16-Jan-09 12:03 

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

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