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

  • SEARCH
  • Home
  • 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 6016531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:59:44+00:00 2026-05-23T02:59:44+00:00

I’m fixing warnings in my program and apparently xmlvalidating reader and xmlschemacollection is obsolete.

  • 0

I’m fixing warnings in my program and apparently xmlvalidating reader and xmlschemacollection is obsolete. The problem is, I’m not quite sure how. Here’s an attempt at “mimicking” the previous validation function with the new one involving xmlschemaset and xmlreader.create. I first declare a schema, and set it using the targeturi string, then add it to the schemaset while setting up the validation event handler. I think my problem is setting up the readers and the input streams. I knew how to do it with xmlvalidating reader, but that isn’t an option if I want to fix these warnings. Here’s the code and attempt. During testing, only the new validation xml code was used, the old one was commented out.

            // New Validation Xml.
            string xsd_file = filename.Substring(0, filename.Length - 3) + "xsd";
            XmlSchema xsd = new XmlSchema();
            xsd.SourceUri = xsd_file;

            XmlSchemaSet ss = new XmlSchemaSet();
            ss.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
            ss.Add(xsd);
            if (ss.Count > 0)
            {
                XmlTextReader r = new XmlTextReader(filename2);
                XmlReaderSettings settings = new XmlReaderSettings();
                settings.ValidationType = ValidationType.Schema;
                settings.Schemas.Add(ss);
                settings.ValidationEventHandler +=new ValidationEventHandler(ValidationCallBack);
                XmlReader reader = XmlReader.Create(filename2, settings);
                while (reader.Read())
                {
                }
                reader.Close();
            }

            // Old Validate XML
            XmlSchemaCollection sc = new XmlSchemaCollection();
            sc.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
            sc.Add(null, xsd_file);
            if (sc.Count > 0)
            {
                XmlTextReader r = new XmlTextReader(filename2);
                XmlValidatingReader v = new XmlValidatingReader(r);
                v.ValidationType = ValidationType.Schema;
                v.Schemas.Add(sc);
                v.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
                while (v.Read())
                {
                }
                v.Close();
            }

    private void ValidationCallBack(object sender, ValidationEventArgs e)
    {
        // If Document Validation Fails
        isvalid = false;
        MessageConsole.Text = "INVALID. Check message and datagridview table.";
        richTextBox1.Text = "The document is invalid: " + e.Message;
    }

Unfortunately, when I run the program and try to validate an invalid xml document, it gives me an error like this: “The ‘URNLookup’ element is not declared.” The URNLookup element is the root element of the xml file. I can always go back to the old validation method, but those warnings scare me.

Any help is appreciated greatly. Thank you in advance! I’ll be happy to provide additional information if I missed any.

  • tf.rz (.NET 3.5 SP1, Visual Studio C# 2008)
  • 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-23T02:59:45+00:00Added an answer on May 23, 2026 at 2:59 am

    I have fixed the issue and it is now working again with no warnings.
    In the New Validation XML:

                // New Validation Xml.
                string xsd_file = filename.Substring(0, filename.Length - 3) + "xsd";
                XmlSchema xsd = new XmlSchema();
                xsd.SourceUri = xsd_file;
    
                XmlSchemaSet ss = new XmlSchemaSet();
                ss.ValidationEventHandler += new ValidationEventHandler(ValidationCallBack);
                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(ValidationCallBack);
                    XmlTextReader r = new XmlTextReader(filename2);
                    using (XmlReader reader = XmlReader.Create(r, settings))
                    {
                        while (reader.Read())
                        {
                        }
                    }
                }
    

    The ss.add was changed to have a namespace, and the file string. settings.schemas.compile() was added, and the insignificant reorganization of the “using(xmlreader reader.. . . .” was added.

    This page helped me a lot: http://msdn.microsoft.com/en-us/library/fe6y1sfe(v=vs.80).aspx It now works.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.