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
Solved

Validate an XML file against an embedded XSD

Posted on 2006-11-21
2
881 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Suggested Solutions

Title # Comments Views Activity
Set value of dynamically created checkboxlist 2 42
C# Desktop Application 3 54
transaction in asp.net, sql server 6 43
Name Space error VS2015 1 25
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

860 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