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 6782535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:45:13+00:00 2026-05-26T16:45:13+00:00

I am having trouble validating serialized data. Ok, so I started with an XSD

  • 0

I am having trouble validating serialized data.

Ok, so I started with an XSD file which I got from some third party. Generated C# classes using xsd tool. Then I added

[XmlAttribute("noNamespaceSchemaLocation", Namespace = System.Xml.Schema.XmlSchema.InstanceNamespace)]
public string SchemaLocation = "http://localhost/schemas/AP_Transactions_10052011.xsd";

to the top level object. The URL in question is obviously accessible from my machine where I am running the code. Then I am serializing it using XmlSerializer, which correctly produces

<?xml version="1.0" encoding="utf-8"?>
<BU_AP_Vendor_Invoices xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:noNamespaceSchemaLocation="http://local.com/schemas/AP_Transactions_10052011.xsd">
...
</BU_AP_Vendor_Invoices>

So far so good.
Now I am trying to validate the file like so:

public static void Validate(TextReader xmlData)
{
    XmlReaderSettings settings = new XmlReaderSettings();
    settings.ValidationType = ValidationType.Schema;
    settings.ValidationFlags = XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ReportValidationWarnings;
    settings.ValidationEventHandler += delegate(object sender, ValidationEventArgs args)
    {
        Console.WriteLine(args.Message);
    };

    using (XmlReader xmlReader = XmlReader.Create(xmlData, settings))
        while (xmlReader.Read()) ;
}

Which results Could not find schema information for the element 'element name' warnings for every element in the XML file. I assume that means the XSD is simply not being loaded.

I was looking at the XmlReaderSettings.Schemas, but how would the reader know what to add there? I assumed that if I don’t add schemas explicitly then magic will simply happen, but that doesn’t seem to work.

Question is how to do this properly?

  • 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-26T16:45:13+00:00Added an answer on May 26, 2026 at 4:45 pm

    Please take a look at this post; the gist is to use XmlSchemaValidationFlags.ProcessSchemaLocation.

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

Sidebar

Related Questions

I'll admit, I'm an XML newbie. I'm having trouble validating some xml against a
I am having trouble validating my xml schema. I get these errors on the
I am having some trouble understanding how to make System Sequence Diagrams, as I
I am having trouble validating my html, my menus are triggering the following error:
I've been rebuilding my site with code igniter and am having trouble validating the
I'm having some trouble creating functions with CoffeeScript, I guess I've missed something. For
I having some trouble trying to figure out how to implement a Rails 3
I'm having some trouble understanding how codeigniters loading works. Well first you have the
I'm running into some trouble validating uploaded images using the new IValidatabeObject interface in
I'm doing some form validation, and I'm having trouble with what I'm trying to

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.