'How to convert bytes to Xsd Schema in C#
i am actually trying to convert the bytes stream Xsd file into Xsd Schema but was unable to do it through the below code
Stream streamXsdd = new MemoryStream(File.ReadAllBytes(path + "\\input.xsd"));
XmlSchema xsdDoc = new XmlSchema();
xsdDoc.Write(streamXsdd); OR Read(streamXsdd,validationeventhandler);
// i thought the above are used for conversion but they are not.
XmlSchemaSet tempSchemaDocs = new XmlSchemaSet();
tempSchemaDocs.Add(xsdDoc);
but above does not convert it. Is there any other way to do it ?
Solution 1:[1]
The docs suggest you would want to use XmlSchema.Read.
However this is a static method on XmlSchema so your code would change to be more like
Stream streamXsdd = new MemoryStream(File.ReadAllBytes(path + "\\input.xsd"));
XmlSchema xsdDoc = XmlSchema.Read(streamXsddd, validationeventhandler);
XmlSchemaSet tempSchemaDocs = new XmlSchemaSet();
tempSchemaDocs.Add(xsdDoc);
Could it be that your Read wasn't working because you were effectively discarding the result, as it returns a new instance, rather than populating an existing one?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | hwoodiwiss |
