Validator w3 RSS Invalid - RSS 未使用 PHP 显示提要 [重复]

Posted

技术标签:

【中文标题】Validator w3 RSS Invalid - RSS 未使用 PHP 显示提要 [重复]【英文标题】:Validator w3 RSS Invalid - RSS not showing the feed by using PHP [duplicate] 【发布时间】:2015-05-07 05:06:09 【问题描述】:

我是使用 php 创建 RSS 的新手。我搜索了一些参考资料,似乎我的提要基于validator.w3.org 出现错误或无效的 RSS。 我也读过这个link。但这根本没有帮助。

我看到它在line 10 columns 322 中包含错误。这与我在 Google Chrome 中看到的相同(但在 mozilla 中不起作用)。 错误似乎是<br><br>。而且,我想知道 RSS 是否允许任何模式的提要而不是纯文本。

此外,我使用NicEditor 获取文章内容发布并保存在数据库和提要表中。

这是 Feed 测试链接: test_site

这是我在 PHP 扩展中创建 RSS 的代码:

<?php
include_once('pdo_con.php');
?>
<?php
$qryArtl = $mydb->prepare('SELECT * FROM feeder ORDER BY id DESC');
$qryArtl->execute();
    //start creating RSS
    header("Content-type: text/xml");

    echo "<?xml version='1.0' encoding='UTF-8'?>
    <rss version='2.0'>
    <channel>
    <title>Rama Academy: Solusi Belajar Efektif dengan Zenius 
Education</title>
    <link>http://www.blabla.com/</link>
    <description>Cara Belajar Santai, Efektif dan Efisien dengan Zenius 
Learning Revolution | Ramaacademy.com - (C) 2015</description>
    <language>en-us</language>";

$varA = $qryArtl->fetchAll();
foreach ($varA as $displvarA) 
    $contID=$displvarA['id'];
    $linkz=$displvarA['link'];
    $deskripsi_rss=$displvarA['description'];
    $titlejudul=$displvarA['title'];

    //grab the content
    $title=$displvarA['title'];
    $link=$displvarA['link'];
    $description=$displvarA['description'];

    echo "<item>
    <title>$titlejudul</title>
    <link>$linkz</link>
    <description>$deskripsi_rss</description>
    </item>";
    
    echo "</channel></rss>";

?>

以下文字只是我从谷歌获取的示例:

You've moved your site to a new domain, and you want to make the 
transition as seamless as possible.
    People access your site through several different URLs. If, for
 example, your home page can be reached in multiple ways - for instance, 
http://example.com/home, http://home.example.com, or 
http://www.example.com - it's a good idea to pick one of those URLs as 
your preferred (canonical) destination, and use 301 redirects to send 
traffic from the other URLs to your preferred URL. You can also use 
Webmaster Tools to set your preferred domain.

我的问题是: html 格式是否会导致错误?如果是,我怎样才能使它经过验证的 RSS?并且,如果可以的话,请给我推荐一个更好的。 感谢您的帮助!

【问题讨论】:

【参考方案1】:

如果您将 HTML 添加到提要中,则应使用 CDATA 以使其正常工作并有效。

这里有更多信息:https://amittechlab.wordpress.com/2011/03/02/use-cdata-in-rss-feed-to-add-html-and-links/

【讨论】:

好的,我先试试 太好了,伙计 ^_^ 非常感谢:* 只是简单的答案,巨大的结果。再次感谢:D(嗯,需要 5 分钟才能解决:p 没问题,很高兴我能帮上忙 :)

以上是关于Validator w3 RSS Invalid - RSS 未使用 PHP 显示提要 [重复]的主要内容,如果未能解决你的问题,请参考以下文章

Invalid prop: custom validator check failed for prop "pagination".

Invalid prop: custom validator check failed for prop "pagerCount"的报错

Vue Element遇警告:[Vue warn]: Invalid prop: custom validator check failed for prop "type".(代码

Vue——解决[Vue warn]: Invalid prop: custom validator check failed for prop "index". found in

RSS 语法

RSS