XML文件内部写法--引入DTD规范

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pets[
<!ELEMENT pets (dogs,penguins)>    --引入DTD规范XML文件时,DTD文件的编写应注意:红色字体与蓝色字体之间应该要有空格
<!ELEMENT dogs (dog*)>
<!ATTLIST dog id CDATA #REQUIRED>
<!ELEMENT dog (health,love,decHealth,incLove)>
<!ELEMENT penguins (penguin*)>
<!ATTLIST penguin id CDATA #REQUIRED>
<!ELEMENT penguin (health,love,decHealth,incLove)>
<!ELEMENT health (#PCDATA)>
<!ELEMENT love (#PCDATA)>
<!ELEMENT dechealth (#PCDATA)>
<!ELEMENT inclove (#PCDATA)>
]>
<pet>
  <dogs>
	  <dog id="1">
		<health>100</health>
		<love>0</love>
		<decHealth>18</decHealth>
		<incLove>10</incLove>
	  </dog>
  </dogs>
	<dogs>
	  <dog id="2">
		<health>100</health>
		<love>0</love>
		<decHealth>18</decHealth>
		<incLove>10</incLove>
	  </dog>
	</dogs>
	<dogs>
	  <dog id="3">
		<health>100</health>
		<love>0</love>
		<decHealth>28</decHealth>
		<incLove>30</incLove>
	  </dog>
	</dogs>
	<penguins>
	  <penguin id="4">
		<health>100</health>
		<love>0</love>
		<dechealth>15</dechealth>
		<incLove>8</incLove>
	  </penguin>
	</penguins>
</pet>

  

posted on 2015-05-11 21:35  msl毛圣林  阅读(801)  评论(0编辑  收藏  举报

导航