2011-05-27 46 views
0

我想格式化我的RSS提要內容。像嵌入一些帶有描述標籤的信息。我創建WordPress的RSS提要,並試圖創造RSS 2.0如何格式化RSS提要內容描述?

<?xml version="1.0"?> 
<rss version="2.0"> 
<channel> 
<item> 
<title>firstquestion</title> 
<url>test-domain.com</url> 
<description>This is some ifnormation on the description. The below are the answers for the new question</description></item> 
</channel> 
</rss> 

現在,我想格式化或進一步一些表格的信息有特殊字符附着,即使HTML標籤的格式化<description> ...哪有我這樣做?

當我只是插入,它給了我一個錯誤?

回答

1

您可以在description元素中包含HTML,但必須使用htmlspecialchars對其進行編碼。

$description = '<strong>Strong formatting</strong> or <em>emphasis</em>.'; 
$item = '<item> 
      <title>firstquestion</title> 
      <url>test-domain.com</url> 
      <description>'.htmlspecialchars($description).'</description> 
     </item>'; 
+0

太感謝你了,效果不錯 – logudotcom 2011-05-27 11:52:58

1

使用CDATA部分:

$description = '<strong>Strong formatting</strong> or <em>emphasis</em>.'; 
$item = '<item> 
      <title>firstquestion</title> 
      <url>test-domain.com</url> 
      <description><![CDATA['.$description.']]></description> 
     </item>';