XML Parsing Error: junk after document element

XML Parsing Error: junk after document element

by Brad Parks -
Number of replies: 1
Hi there;

I've been doing some Moodle development in 1.8.4, and have had a problem appear intermittently, that wasn't obvious to me why it was happening...

All it was is that I was getting the error:

XML Parsing Error: junk after document element
<br>

Sometimes, not all the time, when loading certain pages.... All this error message was trying to tell me was that the HTML I was generating from my custom blocks, etc, was not XHTML compliant, as Moodle requires!

The reason I didn't realize what the problme was right off is that it doesn't happen every time, only 1 out of 50 times.... Really strange! But regardless, it was an easy fix, so if anyone else gets the above error message, check to make sure you html is XHTML!

Thanks,

Brad
Average of ratings: -
In reply to Brad Parks

Re: XML Parsing Error: junk after document element

by Brad Parks -
One more thing to note! When this happens, it can also mean that you've got a bug in your PHP code, and PHP is reporting the errors to the browser, and when doing so it inserts a warning message like:

Warning: ....

which breaks your XHTML compliance as well. So if you see the XML Parsing Error message, view the source of the page, and search for "Warning" and you'll possibly find a PHP error... So your template may be ok (XHTML compliance wise), but a PHP bug is breaking it instead!

Brad