首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

验证xml的schema的写法

2012-05-08 
求一个验证xml的schema的写法XML codepersonpersoninfoname/namefatherpersoninfoname/nam

求一个验证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>

热点排行