• Register
0 votes
166 views

Problem :

My blog feed showing me following 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

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

I have also faced the same issue in the recent past. I did lot of research on it to get solution on the issue.  I did following steps to resolve the issue. I found that firstly you need to create the php file e.g. whitespacefix.php on your wordpress root directory with below 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");

?>

Now open your index.php file and add the below line right after <?php tag

include('whitespacefix.php');

 

If above solution is not helpful for you then you can try the solution given below

Please check if one of the files included in either your theme, or a plugin, has an empty blank line before the starting of the file.

Firstly please deactivate all plugins, after that try to load your sitemap.xml link. If it works now, then one of the plugins is the culprit. If it still does not work, then you need to move on...

Secondly, just go through each and every one of the .php files that make up your WordPress theme. Find any starting empty lines.

Third, just reinstall WordPress core installation. If it still not working, then contact a developer to do the some deep diving into your source code.

9 7 4
38,600 points

Related questions

0 votes
1 answer 10 views
10 views
Problem: I have an XML file songs.xml as partially shown below: <?xml version="1.0" encoding="utf-8"?> <Event status="happened"> <Song title="Erase and rewind"> <Artist name="The Cardigans" ID="340900"> </Artist> <Info StartTime="22:22:13" JazlerID="8310" PlayListerID="" /> </Song> </Event> I need to parse such file and get all the fields like: Song Title: Artist: Start Time: ID:
asked 5 days ago Mashhoodch 5.6k points
0 votes
1 answer 245 views
245 views
Problem : Currently I am trying to learn the Apache Maven. I have tried to write below code in Eclipse but it is giving below error to me: Error Message: &ldquo;No grammar constraints (DTD or XML Schema) referenced in the document&rdquo; My Code : <project xmlns="http:// ... > <version>3.0</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins>
asked Feb 27, 2020 mphil 2.3k points
0 votes
1 answer 41 views
41 views
Problem: Hi, i upgraded the wordpress to Wordpress 5..2.2 but it popups a notification that my server is running an older version. Can anyone suggest me the best solution.
asked Nov 2, 2020 prog_learner 2.5k points
1 vote
1 answer 83 views
83 views
Problem: I am very new to Web.xml coding. Currently I am facing serious problem because of my web.xml file. If I try to run my Apache tomcat 8 server then every time it shows me below error: Server tomcat v8.0 server at localhost failed to start. in eclipse. If I ... . This error made my life like the hell. So I am looking for the help from web.xml expert who can help me in fixing my problem.
asked May 18, 2020 Martin K 6.6k points
0 votes
1 answer 9 views
9 views
I am beginner in SOAP request and response. We are running a project where our client has provided us their WSDL file. Specially they need an attribute which accepts multiple values.
asked Sep 28, 2020 Daniel Anderson 4k points
0 votes
1 answer 39 views
39 views
All of the following values can be stored in a column that&rsquo;s defined as decimal(6,2), except A) -246.29 B) 0 C) 2479.95 D) 32492.05 What is the correct answer? Explain in detail why?
asked Jun 11, 2020 Hiba Waqar 160 points
0 votes
1 answer 7 views
7 views
Can anyone help me in some interview questions all related to XML thanks!!
asked Dec 10, 2020 Lucky Guy 930 points
0 votes
1 answer 9 views
9 views
I am trying to display xml data in html page applying JavaScript but some cases i am finding difficulty.
asked Sep 25, 2020 Daniel Anderson 4k points
0 votes
1 answer 186 views
186 views
Problem : I want to run the Eclipse JSF project on the Apache Tomcat on some other computer. I created the WAR file. But, when I try to deploy the WAR and open my Facelet page in Firefox, I usually face only the below error message: &ldquo;This XML file does not appear ... first time when I am trying to run the JSF app without my Eclipse. How is this issue popping up and how can I fix the issue?
asked Jan 3, 2020 alecxe 7.5k points
0 votes
1 answer 382 views
382 views
Problem : I have spent over the 10 hours in finding the exception or the special character to find in the code but I am unable to find it. I have already checked every similar messages in here. I am facing below error: Syntaxerror: json.parse: unexpected character at line 1 ... my form after that I am sending all the inputs to the main.js to validate it. So, I am just looking for the third-eye.
asked Dec 23, 2019 alecxe 7.5k points