Solved

Validate an XML file against an embedded XSD

Posted on 2006-11-21
2
885 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 30

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

623 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