【发布时间】:2018-05-07 10:34:10
【问题描述】:
我正在编写 XSD 架构和 C# 代码来读取 XML 文件并针对 XSD 进行验证:
XmlDocument myDocument = new XmlDocument();
XmlReaderSettings xmlReaderSettings = new XmlReaderSettings();
xmlReaderSettings.ValidationType = ValidationType.Schema;
xmlReaderSettings.Schemas.Add(null, "MyXsd.xsd");
using (XmlReader xmlReader = XmlReader.Create("MyXml", xmlReaderSettings))
{
myDocument.Load(xmlReader);
}
我对 XSD 不是很有经验,所以我指的是各种网站寻求帮助,但我不断遇到诸如“这将在 XSD1.0 但不适用于 XSD1.1”或“与 XSD2 .0 这样做”。有人可以解释我如何知道或指定将使用哪个版本的 XSD。我正在使用 VS2012 - 我什至不知道这是否相关。
【问题讨论】:
-
参见 IEEE 网站:w3.org/standards/techs/xmlschema#w3c_all
-
@jdweng:W3C,但有趣的是,如果 XSD 起源于 IEEE,它可能会有什么不同。 ;-)
-
W3C 不是 IEEE 分委员会吗?
-
@jdweng:不。你可能会看到不同领域的联合工作组或活动,但它们是独立的组织,IEEE 与 XSD 的开发无关。
标签: c# xml visual-studio-2012 xsd