body, table{font-family: 微软雅黑; font-size: 10pt}
table{border-collapse: collapse; border: solid gray; border-width: 2px 0 2px 0;}
th{border: 1px solid gray; padding: 4px; background-color: #DDD;}
td{border: 1px solid gray; padding: 4px;}
tr:nth-child(2n){background-color: #f8f8f8;}
schema.xsd | myXml.xml |
<?xml version="1.0" encoding="utf-8" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="meihao" //这里必须有 elementFormDefault="qualified"> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson" type="xs:string"/> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="note" type="xs:string" minOccurs="0"/> <xs:element name="quantity" type="xs:positiveInteger"/> <xs:element name="price" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema> | <?xml version="1.0" encoding="utf-8" ?> <shiporder orderid="No.1" xmlns="meihao" //这里随便写,xmlns后面可以像xsd里面一样写一个命名:xmlns:mh xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" //固定;不要也可以,不要的话结果显示就没有这行 xsi:schemaLocation="meihao schema.xsd"> //xsd文件里的空格加上文件名字 <orderperson >名单</orderperson> <shipto> <name>姓名</name> <address>地址</address> <city>城市</city> <country>乡村</country> </shipto> <item> <title>标题</title> <note>注释</note> <quantity>3</quantity> <price>34</price> </item> </shiporder> 注意:书写时候有意的空格分层对程序没有什么影响;闭合标签要成对的写出来,不然出错的时候只会随便显示一行文字 |
//结果截图
05-14 21:26