Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Parsing error : Extra content at the end of the document

Tags:

parsing

xml

extra

Firstly , good day to everyone. I have this script which handles the login to my database : http://pastebin.com/ctUEczRf I used pastebin because it was too long to use code tags. When I run it It returns me this :

This page contains the following errors:

error on line 2 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.

I don't know how to solve it , I never used XML before. This was given to me along with the CMS.

like image 692
user1640328 Avatar asked Sep 01 '12 18:09

user1640328


People also ask

What causes XML parsing error?

The most common cause is encoding errors. There are several basic approaches to solving this: escaping problematic characters ( < becomes &lt; , & becomes &amp; , etc.), escaping entire blocks of text with CDATA sections, or putting an encoding declaration at the start of the feed.


2 Answers

Pasting the XML that's generated is probably what you'd need to do. My guess is that you are generating XML with multiple top-level elements; XML requires that you have a single wrapper element at the top level and have all other elements inside it: it's a tree, not a forest.

My second guess is that you are seeing the error in your Web browser, and it is not being generated by php at all; check your Web server error logs to make sure.

like image 63
barefootliam Avatar answered Sep 17 '22 07:09

barefootliam


Look at the XML. It should look something like the following:

<block>
    <item>Here's an item</item>
    <item>Here's another item</item>
    <item>Here's an item with some sub-items
        <subitem>one</subitem>
        <subitem>two</subitem>
    </item>
</block>

The root of the XML document is the block item; it's the item that encloses and surrounds all of the other items.

If you don't have a root - ie, if the code looks something like this:

<item>Here's a list of items</item>
<item>But there's no root element</item>

Then you'll get the error you describe.

like image 32
piersb Avatar answered Sep 21 '22 07:09

piersb