Fraser
Fraser

Reputation: 14246

XML Parsing Error: XML declaration not well-formed

I've created an XML feed which outputs fine in my local dev environment but on the live server, I get the following error:

XML Parsing Error: XML declaration not well-formed
Location: http://realaussieadventures.com/home/tourFeed
Line Number 1, Column 15:

<?xml version=1.0 ?>
--------------^

I have tried the version with quotes (<?xml version="1.0" ?>) - works on local - without quotes (<?xml version=1.0 ?>) - doesn't work on local or live - and with escaped quotes () - works on local.

Local is a MAMP dev environment.

What is wrong with this?

Upvotes: 6

Views: 35854

Answers (4)

Lyserty
Lyserty

Reputation: 345

I had a similar issue, when I tried to open config file in the browser, here is what I had in my case:

XML Parsing Error: XML declaration not well-formed
Location: http://localhost:8080/job/MyProject/config.xml
Line Number 1, Column 16:
<?xml version='1.1' encoding='UTF-8'?>
---------------^

I tried changing single quotes to double quotes, it didn't help.

But I changed XML version from 1.1 to 1.0 that appears to fix my issue.

Upvotes: 2

shomeax
shomeax

Reputation: 865

Thought the answer is a bit outdated, but as question is pretty top at Google, I'll just leave it here.

Hint: Recheck that your double quotes (") are actual double quotes, e.g. ANSI code 34, not any Unicode double quotation mark (U+201C / U+201D), they may slip into output file by occasion and visually are very hard to track.

Same goes for single quotes, your favorite Unix editor used to write the script may insert apostrophe/grave accent pair instead of single quotes.

You think this is enough? Nope, I once stumbled upon Unicode non-breakable space character (U+00A0) slipped instead of simple ANSI code 32 space between element attributes. Parser failed miserably.

Long story short: use strict ANSI editors to prepare XML-generating boilerplate.

Upvotes: 7

mark
mark

Reputation: 11

Try this:

header("Content-Type: text/xml")
echo " xml version='1.0' encoding='UTF-8' standalone='yes' ";

use single quote in '1.0','UTF-8' etc.. it work for me..

Upvotes: 1

Reagan Ochora
Reagan Ochora

Reputation: 1742

I had the same problem. I realized that I left the version, encoding and the quotes. A well-formed xml has version and encoding.

<?xml version="1.0" encoding="UTF-8"?> this should be able to work. don't leave out the quotes.

Upvotes: 4

Related Questions