我有一個XSD文件,其中包含很多元素。 只有一部分XSD文件需要驗證傳入的XML文件。在C#中僅使用XSD文件的一部分驗證XML文件
例如:
這是有效的XML
<in attr1="9" attr2="0" attr3="0" />
這是XSD文件。只有元素「FindPerson」下名爲「In」的元素才能驗證XML文件。
<xs:element name="WS">
<xs:complexType>
<xs:sequence>
<xs:element name="ELEMENT1">
<xs:complexType>
<xs:sequence>
<xs:element name="FindPerson">
<xs:complexType>
<xs:sequence>
<xs:element name="In">
<xs:complexType>
<xs:attribute name="attr1" type="xs:int"/>
<xs:attribute name="attr2" type="xs:boolean" use="optional" default="0"/>
<xs:attribute name="attr3" type="xs:boolean" use="optional" default="0"/>
</xs:complexType>
</xs:element>
...
有沒有一種方法來驗證XML文件只在C#中的XSD文件的一部分?
謝謝,我會試試這種方式! – Mathieu 2012-04-25 14:52:32