douzhimei8259 2015-03-05 09:53
浏览 36
已采纳

验证器w3 RSS无效 - RSS未使用PHP显示订阅源[重复]

This question already has an answer here:

I'm new in creating RSS with PHP. I have searched some references and it seems that my feeds gets error or invalid RSS based on validator.w3.org. I also has read this link. But it didn't help AT ALL.

I saw that it contains error in line 10 columns 322. This is the same as I saw in Google Chrome (but not work in mozilla). The error seems <br><br>. and, I wonder if RSS doesn't permit any pattern of feed instead of pure texts.

Besides, I use NicEditor to get article content posted and saved in the database and feed-table.

Here's the feed test link: test_site

Here's my codes to create the RSS in PHP extension:

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

?>

This following text is just a sample I fetch from google:

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.

My QUESTION IS: Is the HTML format causes the Error? If it is, How can I make it validated RSS? and, please suggest me the better one if available. Thanks for help!

</div>

展开全部

  • 写回答

1条回答 默认 最新

  • douli1306 2015-03-05 09:58
    关注

    If you are adding HTML to the feed, you should be using CDATA in order to make it work and to be valid.

    Here is some more info: https://amittechlab.wordpress.com/2011/03/02/use-cdata-in-rss-feed-to-add-html-and-links/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?