如何格式化RSS feed内容描述?

问题描述

| 我想格式化我的RSS feed内容。喜欢在Description标签中嵌入一些信息。我正在创建Wordpress Rss feed并尝试创建RSS 2.0
<?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>
现在,我想格式化或进一步格式化一些带有特殊字符的表或信息,甚至以tags1ѭ格式的html标签格式化……我该怎么做? 当我简单地插入时,它给我一个错误?     

解决方法

        您可以在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>\';
    ,        使用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>\';
    

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...