我正在尝试使用 XmlSchema.Read 加载 xsd 文件。它运行时没有错误,我可以看到它从文件中读取命名空间,但我无法从 xsd 文件中读取任何其他数据。
这是我的代码:
public XmlSchema GetXSDFileAsXMLSchema()
{
FileStream fs = new FileStream(path, FileMode.Open);
XmlSchema schema = XmlSchema.Read(fs, new ValidationEventHandler(ValidationCallBack));
return schema;
}
private void ValidationCallBack(object sender, ValidationEventArgs args)
{
return;
}
有人知道为什么元素计数为0吗?
最佳答案
MSDN 说元素只有在调用 Compile() 后才会被填充。在此之前,您可以使用架构的原始元素,例如 Items。
关于c# - XmlSchema.Read 无法正确加载 xsd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4547457/