CodeSnip: Validating XML Data using the XML Schema Definition
page 1 of 4
Published: 02 Feb 2007
Abstract
This code snippet explains how to validate an XML Document with an XSD schema file.
by Uday Denduluri
Feedback
Average Rating: 
Views (Total / Last 10 Days): 40325/ 87

Introduction

The following will help someone understand the validation of XML files against the XML schema definition (XSD). Let us assume that we have an XML file and XSD file. We need to validate this XML file before we perform operations on it. The code snippets shown below are in written in the C# language. Some of the classes used were introduced in .NET Framework 2.0.


View Entire Article

User Comments

Title: CodeSnip: Validating XML Data using the XML Schema Definition   
Name: A Non E Mous
Date: 2009-03-30 7:36:50 AM
Comment:
This does not actually work. I have tried it in VS2008, giving a valid XSD file and an XML file that does not match the schema in any respect and did not get any errors.

When I made the XML file invalid, the XMLDocument.Load call did raise an exception as expected. Invalidating the XSD also caused an exception in Schemas.Add; however, the functionality claimed in the article title is non-existent.
Title: CodeSnip: Validating XML Data using the XML Schema Definition   
Name: my name? Your name? The name of the article?
Date: 2007-03-19 9:30:20 PM
Comment:
This code won't actually compile. That may be my fault, but I am pretty sure that there are some sytaxish errors here:
if(!String.IsNullOrEmpty(ErrorMessage.ToString()))
{
MessageBox.Show(ErrorMessage.ToString());
}
where does ErrorMessage get defined?






Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2017 ASPAlliance.com  |  Page Processed at 2017-06-28 10:09:16 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search