EDN Admin
Well-known member
I need to validate XML documents against an XSD file thats stored as an embedded resource in my project (C# 4.0 VS2010)
I know can load the XSD file into a StreamReader and then into a string using...
Assembly assembly = Assembly.GetExecutingAssembly();<br/>
var schemaStreamReader = new StreamReader(assembly.GetManifestResourceStream("mySchema.xsd"));<br/>
var schemaString = schemaStreamReader.ReadToEnd();
I assumed I could then do something like...
var schema = new XmlSchema();<br/>
schema.Read( schemaStreamReader or schemaString, ... );
But Read wont accept either.
So how can I "wire-up" the output from loading the resource to the XSD validation?
All the steps Ive shown are changeable, except for the givens:
1) I must start with an XSD stored as an embedded resource
2) use that XSD to validate an XML doc that arrives as a string.
Thanks!
DadCat
View the full article
I know can load the XSD file into a StreamReader and then into a string using...
Assembly assembly = Assembly.GetExecutingAssembly();<br/>
var schemaStreamReader = new StreamReader(assembly.GetManifestResourceStream("mySchema.xsd"));<br/>
var schemaString = schemaStreamReader.ReadToEnd();
I assumed I could then do something like...
var schema = new XmlSchema();<br/>
schema.Read( schemaStreamReader or schemaString, ... );
But Read wont accept either.
So how can I "wire-up" the output from loading the resource to the XSD validation?
All the steps Ive shown are changeable, except for the givens:
1) I must start with an XSD stored as an embedded resource
2) use that XSD to validate an XML doc that arrives as a string.
Thanks!
DadCat
View the full article