仅在文档开始处允许XML声明 [英] XML declaration allowed only at the start of the document

查看:130
本文介绍了仅在文档开始处允许XML声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的博客供稿今天显示错误:

My blog feed show error today:

此页面包含以下错误:

This page contains the following errors:

第2行第6列错误:仅在文档开始处允许XML声明

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

我的博客供稿: http://feeds.feedburner.com/klassicblog

我的博客: http://blog.klassicweb.com

推荐答案

这是我找到的解决方案 首先,您在wordpress根字典上创建一个具有以下内容的php文件(whitespacefix.php).

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");
?>

然后打开index.php文件,并在<?php标记之后添加以下行

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

include('whitespacefix.php');

引用自此处

这篇关于仅在文档开始处允许XML声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆