Randy Gilman
Randy Gilman

Reputation: 457

Keep receiving error of well-formed document xml?

I keep receiving an error in the following code:

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>

It keeps giving me the following error: The markup in the document following the root element must be well-formed. Everything seems to be correct, but I cannot figure out what's wrong.

Upvotes: 1

Views: 49

Answers (1)

weivall
weivall

Reputation: 987

You have to add some root element

For example 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>

Instead of root can be any other tag

Upvotes: 1

Related Questions