XML Parsing Error: junk after document element
Since I had to go through about 20 pages to find the cause of this error, I figured I’d throw up one more with the cause that I found. Hopefully it’ll help somebody spend less time debugging the problem than I had to spend.
I’ve got a PHP script outputting XML that’s called from an Ajax script. When I was testing the PHP output I got the error XML Parsing Error: junk after document element after trying to add another section to the XML.
What turned out the be the cause is that in adding the section I wound up with two root elements, so in effect there weren’t any root elements. I wrapped the whole thing in another element and it worked perfectly, 20 minutes later.
Question, Comments...
Do you have more questions. Please either leave a comment below or join us in our new forum.
Hi there!
Thanks so much for sharing this! Worked like a charm.
Best regards
Skashi
Hi,
I got the same error in firefox 3. my xml response looks like the following:
1249370351232{“position”:[],”scheduled_from”:[],”scheduled_to”:[]}
The xml validator says that the message is well-formed, but firefox complains. Can anybody please explain to me what the hell is wrong.
It drives me crazy
he all tags have been removed from my string.
around the number 124.. is an id-tag, and around the {…} is an obj tag, and around both, is an answer tag.
Thanks.
For me too it was the first clicked google item and it gave me the answer for my problem in 2 minutes!
Thanks very much!
after seeing this post, i am able to find the fix very quickly.
- Rajesh