我在以下代码中一直收到错误:
DTD:
<!DOCTYPE periodic[
<!ELEMENT element(symbol, name, atomic_number, atomic_weight)>
<!ELEMENT symbol(#PCDATA)>
<!ELEMENT name(#PCDATA)>
<!ELEMENT atomic_number(#PCDATA)>
<!ELEMENT atomic_weight(#PCDATA)>
]>
XML:
<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->
<periodic>
<symbol>FE</symbol>
<name>Iron</name>
<atomic_number>26</atomic_number>
<atomic_weight>55.845</atomic_weight>
</periodic>
<periodic> <!-- Error occurs right here: "The markup in the document following the root element must be well-formed". -->
<symbol>Ir</symbol>
<name>Iridium</name>
<atomic_number>77</atomic_number>
<atomic_weight>192.217</atomic_weight>
</periodic>
<periodic>
<symbol>P</symbol>
<name>Phosphorus</name>
<atomic_number>15</atomic_number>
<atomic_weight>30.973762</atomic_weight>
</periodic>
<periodic>
<symbol>Uut</symbol>
<name>Ununtrium</name>
<atomic_number>113</atomic_number>
<atomic_weight>284</atomic_weight>
</periodic>
<periodic>
<symbol>Po</symbol>
<name>Polonium</name>
<atomic_number>84</atomic_number>
<atomic_weight>209</atomic_weight>
</periodic>
它不断给我以下错误:根元素后面的文档中的标记必须格式正确。一切似乎都是正确的,但我无法弄清楚是什么错误。
答案 0 :(得分:1)
您必须添加一些根元素
例如root
:
<?xml version="1.0" encoding="UTF-8"?>
<!-- New document created with EditiX at Sun Jul 06 07:25:48 AST 2014 -->
<root>
<periodic>
<symbol>FE</symbol>
<name>Iron</name>
<atomic_number>26</atomic_number>
<atomic_weight>55.845</atomic_weight>
</periodic>
<periodic> <!-- Error occurs right here: "The markup in the document following the root element must be well-formed". -->
<symbol>Ir</symbol>
<name>Iridium</name>
<atomic_number>77</atomic_number>
<atomic_weight>192.217</atomic_weight>
</periodic>
<periodic>
<symbol>P</symbol>
<name>Phosphorus</name>
<atomic_number>15</atomic_number>
<atomic_weight>30.973762</atomic_weight>
</periodic>
<periodic>
<symbol>Uut</symbol>
<name>Ununtrium</name>
<atomic_number>113</atomic_number>
<atomic_weight>284</atomic_weight>
</periodic>
</root>
而不是root
可以是任何其他tag