我有这个xml文件:
data_out.xml
<?xml version="1.0" ?>
<!DOCTYPE allproperty SYSTEM "data_out.dtd">
<allproperty>
<aproperty>
<postcode>ha15rs</postcode>
<price>250</price>
<imagefilename>home2.gif</imagefilename>
<visits>2</visits>
</aproperty>
<aproperty>
<postcode>ha36gs</postcode>
<price>150</price>
<imagefilename>home3.gif</imagefilename>
<visits>1</visits>
</aproperty>
<aproperty>
<postcode>ha27se</postcode>
<price>300</price>
<imagefilename>home4.gif</imagefilename>
<visits>4</visits>
</aproperty>
<aproperty>
<postcode>ha4678</postcode>
<price>200</price>
<imagefilename>home5.gif</imagefilename>
<visits>5</visits>
</aproperty>
</allproperty>
DTD文件
data_out.dtd
<!ELEMENT aproperty (postcode,price,imagefilename,visits)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT imagefilename (#PCDATA)>
<!ELEMENT visits (#PCDATA)>
当我检查“说allproperty
未声明”时,我一直收到错误
答案 0 :(得分:3)
你必须在DTD中正确声明
<!ELEMENT allproperty (aproperty+)>
<!ELEMENT aproperty (postcode,price,imagefilename,visits)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT imagefilename (#PCDATA)>
<!ELEMENT visits (#PCDATA)>