class.dtd
<?xml version="1.0" encoding="UTF-8"?> <!ELEMENT classrooms (classroom+)> <!ELEMENT classroom (grade,classname,students)> <!ATTLIST classroom id ID #REQUIRED> <!ELEMENT classname (#PCDATA)> <!ELEMENT grade (#PCDATA)> <!ELEMENT students (student+)> <!ELEMENT student (id,studentname,age)> <!ELEMENT id (#PCDATA)> <!ELEMENT studentname (#PCDATA)> <!ELEMENT age (#PCDATA)>
class.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE classrooms SYSTEM "class.dtd"> <classrooms> <classroom id="c1"> <grade>2010</grade> <classname>10级计算机应用技术一班</classname> <students> <student> <id>1</id> <studentname>宋发准</studentname> <age>12</age> </student> <student> <id>1</id> <studentname>宋发准</studentname> <age>12</age> </student> </students> </classroom> <classroom id="c2"> <grade>2010</grade> <classname>10级计算机应用技术二班</classname> <students> <student> <id>2</id> <studentname>李四</studentname> <age>22</age> </student> <student> <id>2</id> <studentname>李四</studentname> <age>22</age> </student> </students> </classroom> </classrooms>
?=0次或者1次,+=一次或者多次,*=0次或者多次