What are the valid HTML tags in RSS Feeds?

╄→гoц情女王★ 提交于 2020-01-22 19:02:50

问题


I've looked around, and it doesn't seem like there's any standard of what HTML tags are 'allowed' in RSS - you could put anything in. But the readers I tested only allow certain things.

In my initial testing, it seems like simple styling tags like <b> are fine. So is inline styles like <span style="color:red"> <img>'s seems to work. But <iframe>'s are ignored, as are <script> blocks. Onclick attributes don't work. <style> blocks work in some readers but not others

Is there a general consensus, standard, or compatability site listing what is and isn't supported in what readers? I want to know what the subset of HTMl tags I can use in feeds is.


回答1:


 <title>How to parse full html content in xml feeds</title>
 <description><![CDATA[<html><body>Any code html is valid here like &npsb; 
 and what ever you want to transfer</body></html>]]></description>
 <guid>http://example.com/your-news-id</guid>



回答2:


I don't think there's a standard here - it's all about what the RSS reader itself is willing to implement. So my guess would be that, for example, Google Reader would wash out tags and the like and dangerous HTML and CSS attributes, and then allow whatever other sort of non-blacklisted tag you would dare to include.

So, yeah. There's no specification, and therefore likely no standard - just the same general XSS prevention techniques we see across the whole interwebs. Your only option is to try out various tags that you think may be contentious (though really I'd expect almost anything but CSS styling would be permitted) in different RSS readers to see what happens, or simply to have your content ready to fall back to a more basic format if the desired HTML/CSS is not permitted.

What in particular are you trying to do? You may be able to get better answers if you can specify - or is this just a question of curiosity?




回答3:


I think the 'right' thing to do is either include an xhtml namespace (xmlns:html="http://www.w3.org/1999/xhtml") or put the HTML data in a CDATA section.




回答4:


I don't think there's any "official" answer. It might depend on what level of compatibility you're aiming for.

I'd keep it to the basic text formatting tags (STRONG, EM, etc) and IMG and A and that's about it.




回答5:


In fact, no HTML attributes are allowed in RSS feeds. Only XML tags listed in the specification posted above are allowed. Also, since it is XML, only some Unicode encodings are allowed (e.g. UTF-8). That many RSS providers do not respect the standard is another matter.



来源:https://stackoverflow.com/questions/1140307/what-are-the-valid-html-tags-in-rss-feeds

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!