Solved

Validate an XML file against an embedded XSD

Posted on 2006-11-21
2
883 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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying 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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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