如何解决如何格式化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>\';
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。