【发布时间】: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?并且,如果可以的话,请给我推荐一个更好的。 感谢您的帮助!
【问题讨论】: