40、dom以xml结尾的文件
2016-10-24 23:18
232 查看
1、student.xml文件
2、student.xsd文件
3、country.css
4、hello.xml文件
5、student.dtd文件
<?xml version="1.0" encoding="utf-8" ?> <!-- 1.书写根元素(因为xsd文件的引入是在根元素上进行的) 2.在根元素上书写schemaLocation属性,填入命名空间,和xsd文件位置.(可以引入多个,没对之间用 空格/回车 隔开.) 3.为引入的xsd定义一个前缀.xmlns="http://www.itcast.cn/xml" 4.固定值. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" --> <students xmlns="http://www.itcast.cn/xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.itcast.cn/xml students.xsd" > <student number="ITCAST_0001"> <name>tom</name> <age>18</age> <sex>male</sex> </student> </students>
2、student.xsd文件
<?xml version="1.0"?> <xsd:schema xmlns="http://www.itcast.cn/xml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.itcast.cn/xml" elementFormDefault="qualified"> <xsd:element name="students" type="studentsType"/> <xsd:complexType name="studentsType"> <xsd:sequence> <xsd:element name="student" type="studentType" minOccurs="0" maxOccurs="unbounded"/> </xsd:sequence> </xsd:complexType> <xsd:complexType name="studentType"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="age" type="ageType" /> <xsd:element name="sex" type="sexType" /> </xsd:sequence> <xsd:attribute name="number" type="numberType" use="required"/> </xsd:complexType> <xsd:simpleType name="sexType"> <xsd:restriction base="xsd:string"> <xsd:enumeration value="male"/> <xsd:enumeration value="female"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="ageType"> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="0"/> <xsd:maxInclusive value="120"/> </xsd:restriction> </xsd:simpleType> <xsd:simpleType name="numberType"> <xsd:restriction base="xsd:string"> <xsd:pattern value="ITCAST_\d{4}"/> </xsd:restriction> </xsd:simpleType> </xsd:schema>
3、country.css
c1 { font-size:200px; color:red; } c2 { font-size:100px; color:green; } c3 { font-size:10px; color:yellow; } c4 { font-size:150px; color:blue; }
//country.xml文件 <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="country.css"?> <c> <c1>中国</c1> <c2>美国</c2> <c3>日本</c3> <c4>英国</c4> </c>
4、hello.xml文件
<?xml version="1.0" encoding="gbk" ?> <students> <!-- 下面是一个问题学生 --> <student number="itcast_0001" > <name><tom></name> <age>18</age> <sex>male</sex> <code><![CDATA[<><><><><<><><]]></code> </student> </students>
5、student.dtd文件
<!ELEMENT students (student*) > <!ELEMENT student (name,age,sex)> <!ELEMENT name (#PCDATA) > <!ELEMENT age (#PCDATA) > <!ELEMENT sex (#PCDATA) > <!ATTLIST student number ID #REQUIRED>
相关文章推荐
- 40、dom以xml结尾的文件
- DOM解析xml文件
- Ms XmlDom 异步装载Xml文件
- 如何使用PHP DOM创建动态的XML文件
- 使用SAX或者DOM或者pull解析XML文件
- 利用dom4j生成带dom的xml文件
- 简单的DOM解析XML文件,并实现增,删,改,查的操作
- 如何借助DOM生成XML文件
- Android -使用DOM(文档对象模型)解析XML文件
- xml&dom_sax_dom4j学习笔记(一)SAX解析XML文件
- 使用DOM生成XML的文件属性名和属性值、节点名和节点值
- DOM方式解析XML配置文件,将数据保存成数组
- java DOM解析XML文件
- DOM解析XML文件
- DOM方式读写XML文件
- Android中DOM解析XML文件
- Java使用DOM解析XML的文件属性名和属性值、节点名和节点值
- 利用dom4j生成带dom的xml文件
- Android -使用DOM(文档对象模型)解析XML文件
- DOM解析XML文件例子