Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Parsing Error: XML declaration not well-formed

Tags:

xml

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?

like image 923
Fraser Avatar asked Nov 01 '12 04:11

Fraser


People also ask

What is XML parsing error not well-formed?

"XML Parsing Error" occurs when something is trying to read the XML, not when it is being generated. Also, "not well-formed" usually refers to errors in the structure of the document, such as a missing end-tag, not the characters it contains.

What is an XML parse error?

XML Parser ErrorWhen trying to open an XML document, a parser-error may occur. If the parser encounters an error, it may load an XML document containing the error description. The code example below tries to load an XML document that is not well-formed. You can read more about well-formed XML in XML Syntax.

What causes XML error?

This normally means that there was a problem locating the document (either the document does not exist or there is a problem with permissions). Another possible cause is that the XML parser software is not properly installed. An error was detected while trying to load an XML template file.


3 Answers

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.

like image 90
shomeax Avatar answered Sep 23 '22 01:09

shomeax


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.

like image 21
Reagan Ochora Avatar answered Sep 22 '22 01:09

Reagan Ochora


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.

like image 37
Lyserty Avatar answered Sep 23 '22 01:09

Lyserty