對不起,如果以前有人問過 - 有一個類似標題的問題,但它不是我想要的。使用包含HTML原因的行創建RSS源Feed空白
我正在做的是從數據庫中提取結果並在合適的標籤內打印出來以創建一個RSS提要。
唯一的問題是文章的正文包含html標籤,所以我的rss源無法正確加載。
到目前爲止,我曾嘗試:
$rssfeed .= '<description>' . htmlentities($row['text') . '</description>';
和
$rssfeed .= '<description>' . htmlspecialchars($row['text'], ENT_COMPAT, 'UTF-8') . '</description>';
無論是使用那些只是給了我一個完全空白的飼料。
其實我只是嘗試這樣做藏漢,得到了相同的結果:
$rssfeed .= '<description>' . $row['text']. '</description>';
我更糊塗了,現在是肯定有應該有工作?我唯一能想到的是數據庫中的行對於RSS Feed來說太長了,因爲它是一篇文章和HTML的完整文章。
我不確定它是否會被自動截斷。
任何想法?
UPDATE
這是一些示例輸出:
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title>RSS feed</title>
<link>http://www.12345.co.uk</link>
<description>RSS Feed from 12345.co.uk</description>
<language>en-uk</language>
<copyright>Copyright (C) 2011 12345.co.uk</copyright>
<item>
<title>Wear safe but stylish sunglasses on the slopes</title>
<description><![CDATA["<p>Holidaymakers hitting the slopes this year must remember to pack a pair of sunglasses alongside their skis, one expert has highlighted.</p>
<p>Dharmesh Patel, chairman of the Eyecare Trust, noted that UV protective eyewear is a must for skiers.</p>
<p>Posted by xxxxx</p>v"]]>
</description>
<link></link>
<pubDate>Mon, 03 Oct 2011 16:57:09 +0000</pubDate>
</item>
您不關閉「」或「」標籤。 –
一旦我複製了它,我一定是錯誤地將其刪除了 - 文章非常龐大,所以我只保留了幾行 - 我肯定會在我的PHP代碼中關閉它們。 – martincarlin87