读书人

验证xml的schema的写法

发布时间: 2012-05-08 22:09:41 作者: rapoo

求一个验证xml的schema的写法

XML code
<person>    <personinfo>        <name></name>        <father>            <personinfo>                <name></name>                <father>                    ……                </father>            </personinfo>        </father>    </personinfo></person>


就是想用一个schema验证子孙N代的校验,看了相关资料,嵌套没搞明白。呵呵,希望可以给一个完善一点的xsd,有相关的说明更好了。

[解决办法]
xml中一元素属性又有值的schema的法.

 如下:

  例如:下面的元素的法:

<price days="12">5500</price>

schema的法:

     <xs:element name="price" maxOccurs="2">
<xs:complexType mixed="true">
<xs:attribute name="days">
<xs:simpleType>
<xs:restriction base="xs:integer"></xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
</xs:element>

读书人网 >C#

热点推荐