[英]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.