[英]How to convert bytes to Xsd Schema in C#
我实际上正在尝试将字节 stream Xsd 文件转换为 Xsd 模式,但无法通过以下代码完成
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);
但上面没有转换它。 还有其他方法吗?
文档建议您使用XmlSchema.Read
。
但是,这是XmlSchema
上的 static 方法,因此您的代码会变得更像
Stream streamXsdd = new MemoryStream(File.ReadAllBytes(path + "\\input.xsd"));
XmlSchema xsdDoc = XmlSchema.Read(streamXsddd, validationeventhandler);
XmlSchemaSet tempSchemaDocs = new XmlSchemaSet();
tempSchemaDocs.Add(xsdDoc);
可能是您的Read
没有工作是因为您有效地丢弃了结果,因为它返回一个新实例,而不是填充现有实例?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.