XML parsing error: XML declaration allowed only at the start of the document

6 views
Skip to first unread message

Lei

unread,
Mar 10, 2013, 2:01:47 PM3/10/13
to programmin...@googlegroups.com
When using php to parse database results to xml, sometimes we will confront the follwoing error:
XML declaration allowed only at the start of the document
how to solve this one?

Lei

unread,
Mar 13, 2013, 1:11:44 PM3/13/13
to
Check the php tag at the beginning and make sure it doesn't have any white space at the first line
For Strict XML parser, you need to make sure you only include "hidden" script in your xml parser php file. What I mean is if you have similar things like this:
#incldue_one(another.php)
Make sure in your another.php you didn't have anything like html tags and contexts which will show up in this xml file to make it invalid.
Reply all
Reply to author
Forward
0 new messages