Solved

Validate an XML file against an embedded XSD

Posted on 2006-11-21
2
878 Views
Last Modified: 2012-05-05
Hi,

I'm trying to validate a user specified XML file against an embedded XSD.

I have the xml path as a stiring and I get the schema using the following,

Stream schema = Assembly.GetExecutingAssembly().GetManifestResourceStream(schema);

but I am having trouble using the schema.  Is there any way I can convert this steam to an XmlSchema?  This would make everything a little easier for me.

Thanks.
0
Comment
Question by:VanLouin
2 Comments
 

Author Comment

by:VanLouin
ID: 17986263
Thought I should maybe add a little more of the code I have (which isn't much atm).


public bool ValidateXML(string xmlDocLocation)
{
      string schema = "Checker.check.xsl";            // string for schema to load
      XmlDocument xmlDoc;

      try
      {
            Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(schema);  // grab schema

      }                               
      catch (Exception e)
      {
            Console.Out.WriteLine(e.ToString());
      }

      return m_isValid;
}

I have no problems getting the schema but I just cant seem to use it!

Thanks again.
0
 
LVL 29

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 18000764
In the
             Stream schemaStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(schema);
is the "schema" an xml file?

If yes you may try something like - you'll get your xsd as an XmlDocument:

            XmlDocument doc = new XmlDocument();
            try
            {
                doc.Load(schemaStream );
            }
            catch (Exception e)
            {
                //....
            }
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video discusses moving either the default database or any database to a new volume.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now