Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Validate an XML file against an embedded XSD

Posted on 2006-11-21
2
Medium Priority
?
887 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 1000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

704 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