Out of the corner of my eye

Exploring HumanStateSpace

Out of the corner of my eye header image 2

DOMDocument::LoadXML Extra content at the end of the document in Entity…

February 19th, 2008 · No Comments

This is one of those tricky XML things that can trip up the unwary. Looks like a lot of people have had trouble with this as there’s plenty of hits on Google with people asking questions but I couldn’t find an answer.

You’ll be seeing something like:

Warning: DOMDocument::load() [function.load]: Extra content at the end of the document in Entity, line…

The reason this happens is because your XML is in fact not well-formed. Because in XSL you often use HTML tags in your XML, it can catch you out though.

My problem was I had a table with some results in it from XML. The XML was well-formed because the table tag was the root of the document. However I then added some more markup after the table, and got the “extra content at the end of the document” warning. It took a few minutes of head scratching before I realised what the problem was - I was thinking of it in terms of the output I wanted: an html fragment, not what it actually was: an XML document. Tags are arbitrary in XML so the table tag was the doc’s root node. To stop the warning, all I had to do was move the extra content inside the root of the document, which I did by adding a div around everything.

Hope this helps other people learning the dark arts of XSL transforms!

Tags: Web dev

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment