简单xml与其对应的dtd

1,建立一个学生名册的xml

<?xml version="1.0" encoding="gb2312"?>
<!DOCTYPE studentregister SYSTEM "C:\Users\Administrator\Desktop\Untitled10.dtd">
<studentregister>
<student number="A1">
<name>张三</name>
<sex>男</sex>
<age>20</age>
</student>
<student number="A2">
<name>李四</name>
<sex>女</sex>
<age>19</age>
</student>
<student number="A3">
<name>王二</name>
<sex>男</sex>
<age>21</age>
</student>
</studentregister>

对于dtd

<!DOCTYPE studentregister SYSTEM "C:\Users\Administrator\Desktop\Untitled10.dtd">是用来寻找所对应的外部dtd

加*允许出现0到多次


<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT studentregister (student*)>
<!ELEMENT student (name,sex,age)>
<!ATTLIST student number NMTOKEN #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT sex (#PCDATA)>
<!ELEMENT age (#PCDATA)>

2.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE NEWSPAPER SYSTEM "C:\Users\Administrator\Desktop\Untitled12.dtd">
<NEWSPAPER>
 <ARTICLE AUTHOR="we" EDITOR="we" DATE="rf" EDITION="rf">
  <HEADLINE>&NEWSPAPE;</HEADLINE>
  <BYLIVE>&PUBLISHER;</BYLIVE>
  <LEAD>&COPYRIGHT;</LEAD>
  <BODY>rf</BODY>
  <NOTES>rf</NOTES>
 </ARTICLE>
</NEWSPAPER>

对应的dtd

<!ENTITY NEWSPAPE "vervet Logic Times">是实体的引用内容,在对应xml中,实体引用时记得加&,记得命名,记得最后加上“;”,

“+”表示1到多次出现;

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT NEWSPAPER (ARTICLE+)>
<!ELEMENT ARTICLE (HEADLINE,BYLIVE,LEAD,BODY,NOTES)>
<!ELEMENT HEADLINE (#PCDATA)>
<!ELEMENT BYLIVE (#PCDATA)>
<!ELEMENT LEAD (#PCDATA)>
<!ELEMENT BODY (#PCDATA)>
<!ELEMENT NOTES (#PCDATA)>
<!ATTLIST ARTICLE AUTHOR CDATA #REQUIRED>
<!ATTLIST ARTICLE EDITOR CDATA #IMPLIED>
<!ATTLIST ARTICLE DATE CDATA #IMPLIED>
<!ATTLIST ARTICLE EDITION CDATA #IMPLIED>
<!ENTITY NEWSPAPE "vervet Logic Times">
<!ENTITY PUBLISHER "vervet Logic Press">
<!ENTITY COPYRIGHT "Copyright 1998 Vervet Logic Press">



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

洋葱ycy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值