Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7685117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:10:52+00:00 2026-05-31T19:10:52+00:00

Have have been trying to make a validator for my xml files. I have

  • 0

Have have been trying to make a validator for my xml files. I have used some of the other examples that can be found on this site (like How to validate an XML document?).

I just don’t see it working the way I expect. What does actually get validated?

Almost no matter what I change in the xml file, the validator dosent sees it as an error. I thought the validator would see if the xml file contains an element not defined in the xsd. The validator only catches normal xml syntax errors.

So whats the point of using the xsd if it doesn’t have an influence?

My validator

string xsd_file = "Message.xsd";
XmlSchema xsd = new XmlSchema();
xsd.SourceUri = xsd_file;

XmlSchemaSet ss = new XmlSchemaSet();
ss.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);
ss.Add(null, xsd_file);
if (ss.Count > 0)
{
    XmlReaderSettings settings = new XmlReaderSettings();
    settings.ValidationType = ValidationType.Schema;
    settings.Schemas.Add(ss);
    settings.Schemas.Compile();
    settings.ValidationEventHandler += new ValidationEventHandler(ValidationEventHandler);
    XmlTextReader r = new XmlTextReader(filepath);
    using (XmlReader reader = XmlReader.Create(r, settings))
    {
        try
        {
            while (reader.Read())
            {
            }
        }
        catch (XmlException ex)
        {

            throw;
        }                        
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:10:53+00:00Added an answer on May 31, 2026 at 7:10 pm

    The code for the validation eventhandler is missing.

    Looking at my working code which is slightly different I have this

    settings.ValidationFlags = XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ReportValidationFlags;
    

    Can’t remember why I had to add it though.

    First thing to do is make sure the eventhandler is getting triggered, after that it may be a problem with your xsd.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been trying to make this to be a little jQuery plugin that
I have been trying to make sense of some claims that Appcelerator Titanium makes.
I have been trying to test my application to make sure that all the
I have been trying to make a method where the user can input a
I have been trying to make it so that when i right click a
I have been trying to make a layout for an Android app that functions
I have been trying to make my website performs well. One way that may
I have been trying to make a user login page that, when the user
I have been trying to make a case for using Python at my work.
I have been trying to make a div fade in evey 30sec and out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.