【问题标题】:How to validate subset of XML, against complete XML schema in c#?如何根据 C# 中的完整 XML 模式验证 XML 的子集?
【发布时间】:2016-01-15 15:01:09
【问题描述】:

完整的 XML 架构:

<xs:schema>
 <xs:element name="Root">
  <xs:element name="Element0" type="xs:string" minOccurs="0" maxOccurs="1"/>
  <xs:element name="Element1" type="xs:string" minOccurs="0" maxOccurs="1"/>
  <xs:element name="Element2" type="xs:string" minOccurs="0" maxOccurs="1"/>
 </xs:element>
</xs:schema>

子集示例 XML:

<Root>
 <Element1>Sample Text</Element1>
</Root>

如何根据提供的架构验证示例 XML?

【问题讨论】:

标签: c# xml


【解决方案1】:

System.Xml.Schema 命名空间包含使用 XSD 验证 XML 的类。

在 MSDN 中查看此说明:

https://msdn.microsoft.com/en-us/library/bb387037.aspx

【讨论】:

    猜你喜欢
    • 2010-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-26
    • 2011-07-07
    • 1970-01-01
    • 1970-01-01
    • 2013-06-14
    相关资源
    最近更新 更多