DTD简单介绍
classroom.dtd
<?xml version="1.0" encoding="UTF-8"?> <!ELEMENT classromm (className,grade,students+)> <!ATTLIST classromm id ID #REQUIRED> <!ELEMENT className (#PCDATA)> <!ELEMENT grade (#PCDATA)> <!ELEMENT students (student+)> <!ELEMENT student (id,stuName,age)> <!ELEMENT id (#PCDATA)> <!ELEMENT stuName (#PCDATA)> <!ELEMENT age (#PCDATA)>
classroom.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE classrom SYSTEM "classroom.dtd"> <classrom id="c1"> <className>14bling</className> <grade>2014</grade> <students> <student> <id>1</id> <stuName>bling</stuName> <age>23</age> </student> <student> <id>2</id> <stuName>jun</stuName> <age>20</age> </student> </students> </classrom>
GitBug源码地址:https://github.com/WebServcie/02_dtd