Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML declaration allowed only at the start of the document

My blog feed show error today:

This page contains the following errors:

error on line 2 at column 6: XML declaration allowed only at the start of the document

Below is a rendering of the page up to the first error

My blog feed: http://feeds.feedburner.com/klassicblog

My blog: http://blog.klassicweb.com

like image 315
samir panchal Avatar asked Feb 04 '13 11:02

samir panchal


People also ask

Does XML always start with?

A well-formed XML document entity always has "<" as its first non-whitespace character. A well-formed external general parsed entity need not start with "<". So if by "a XML" you mean "a well-formed XML document entity", then the answer is "no".

Which of the following are correct rule for XML declaration?

Rules. If the XML declaration is present in the XML, it must be placed as the first line in the XML document. If the XML declaration is included, it must contain version number attribute. The Parameter names and values are case-sensitive.

What is XML declaration used for?

The XML Declaration provides basic information about the format for the rest of the XML document. It takes the form of a Processing Instruction and can have the attributes version, encoding and standalone.


2 Answers

Here is the solution I found First you create a php file (whitespacefix.php) on the wordpress root dictory with following content.

<?php
function ___wejns_wp_whitespace_fix($input) {
    $allowed = false;
    $found = false;
    foreach (headers_list() as $header) {
        if (preg_match("/^content-type:\\s+(text\\/|application\\/((xhtml|atom|rss)\\+xml|xml))/i", $header)) {
            $allowed = true;
        }
        if (preg_match("/^content-type:\\s+/i", $header)) {
            $found = true;
        }
    }
    if ($allowed || !$found) {
        return preg_replace("/\\A\\s*/m", "", $input);
    } else {
        return $input;
    }
}
ob_start("___wejns_wp_whitespace_fix");
?>

Then open the index.php file and add the following line right after <?php tag

include('whitespacefix.php');

Referenced from here

like image 108
Asce4s Avatar answered Oct 08 '22 03:10

Asce4s


Your xml document starts with a new-line.

like image 33
Evert Avatar answered Oct 08 '22 03:10

Evert