source

문서의 시작 부분에만 XML 선언이 허용됨

ittop 2023. 9. 19. 21:24
반응형

문서의 시작 부분에만 XML 선언이 허용됨

오늘 블로그 피드 표시 오류:

이 페이지에는 다음 오류가 있습니다.

6열의 2행 오류: 문서의 시작 부분에만 XML 선언이 허용됨

아래는 첫번째 오류까지 페이지를 렌더링한 것입니다.

나의 블로그 피드: http://feeds.feedburner.com/klassicblog

나의 블로그: http://blog.klassicweb.com

여기 내가 찾은 해결책이 있습니다. 먼저 당신은 wordpress root dictory에 다음 내용의 php 파일(whitespacefix.php)을 만듭니다.

<?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꼬리표를 붙이다

include('whitespacefix.php');

여기서 참조

xml 문서는 새 줄로 시작합니다.

페이지의 모든 페이지(사이트 맵 포함)에는 맨 처음에 빈 줄이 들어 있습니다.(HTML 소스 참조) 사이트 맵을 수정하려면 이 줄을 제거해야 합니다.다음 단계를 시도해 볼 수 있습니다.

wp-config.php 파일에서 대괄호로 표시된 섹션 외부의 빈 줄이 있는지 확인합니다.

테마의 기능을 확인합니다.괄호로 표시된 섹션 외부의 빈 줄에 대한 php 파일.

문제의 원인이 되는 플러그인을 분리할 때까지 플러그인을 하나씩 비활성화하고 다시 확인합니다(How To Check For Plugin Conflicts).

최종 php ?>는 모든 PHP 코드 파일 - 모듈, 포함 등(예: wp-config.php, functions.php, ...)에서 생략되어야 합니다.

함수의 맨 끝에 빈 줄이 1개 이상 있어야 합니다.word press를 사용하는 경우 php 파일.

이 빈 줄만 제거하면 오류가 발생합니다.

오류에 대해 더 알고 싶다면, 다음 기사를 읽어보세요: http://www.am22tech.com/fix-xml-declaration-rss-feed-error/

테마에 포함된 파일 중 하나 또는 플러그인이 시작하기 전에 빈 줄이 있음

먼저 모든 플러그인을 비활성화하고 sitemap.xml 링크를 로드합니다.지금 작동이 된다면, 당신의 플러그인 중 하나가 범인입니다.그래도 안 되면 다음 단계로 넘어가...

둘째, WordPress 테마를 구성하는 .php 파일 하나하나를 살펴봅니다.시작할 항목 찾기

셋째, 워드프레스 코어 설치를 다시 설치합니다.그래도 작동하지 않으면 개발자에게 연락하여 소스 코드를 자세히 살펴봅니다.

문제는 잘못된 형식의 플러그인 파일 또는 함수 파일이며, 파일 끝에 빈 줄이 추가로 포함되어 있을 가능성이 높습니다.

WordPress 플러그인 목록을 한 탭에서 열어서 이 문제를 해결했습니다.

/wp-admin/plugins.php

두 번째 탭에서 사이트 맵을 엽니다.

/sitemap_index.xml

그런 다음 원인을 찾을 때까지 이 논리를 따르기만 하면 됩니다.

Deactivate five plugins starting from the top.

if (sitemap shows without errors) {
    Activate four of the latest five to be deactivated and visit the sitemap again.

    if (sitemap shows without errors) { 
        The currently deactivated plugin is at fault. You must reach out to the plugin developer or format the code removing the extra spacing at the beginning or tail of the file.
    else {
        Activate the deactivated plugin and choose one of the other four and deactivate.
    }
} else {
    Reactivate these five deactivated plugins and move onto the next five plugins and deactivate.
}

언급URL : https://stackoverflow.com/questions/14685893/xml-declaration-allowed-only-at-the-start-of-the-document

반응형