0

I'm encountering this error message 'Extra content at the end of the document in XML' in my browser when displaying this XML document, what should I do to fix the problem?

<personnel>
    <person id='demo'>
        <firstname> Ali </firstname>
        <lastname> Adam </lastname>
        <title> Doc</title>
        <sector> R&D </sector>
    </person>
</personnel>
<personnel>
    <person id='demo2'>
        <firstname> Salem</firstname>
        <lastname> Tarek </lastname>
        <title> Dev </title>
        <sector> Tech </sector>
    </person>
</personnel>
Spike
  • 1
  • 1
  • 1
    Is that your whole document? Because it has no root tag. There should be a single tag at root level that would contain your two `` tags. If your error mentions a line and column I assume they correspond to the start of the second `` tag. – Aaron Dec 12 '21 at 14:38
  • If you do have a root tag, check for control characters. If you're on linux use `cat -A` and learn about the caret notation it uses to display them (look in particular for `^M`). If you're on windows check if your editor as an option to display all characters, often represented by the ¶ symbol – Aaron Dec 12 '21 at 14:40
  • XML documents must have a single root element. As @Aaron has said, yours does not; it has two. Either wrap both in a single element, or delete all but the first element. Your case as posted is #2 in the answer to the duplicate Q/A, but watch out for the other cases if your problem persists. – kjhughes Dec 12 '21 at 15:45
  • Thanks a lot to all of you. Indeed, the problem was solved by wrapping the document inside one single root element. – Spike Dec 13 '21 at 00:17

0 Answers0