Whats the best way to pass html embed code via rss feed to a rss parser in php?

后端 未结 5 587
小蘑菇
小蘑菇 2021-01-20 21:52

Im trying to put an html embed code for a flash video into the rss feed, which will then be parser by a parser (magpie) on my other site. How shoul

相关标签:
5条回答
  • 2021-01-20 22:22

    RSS is XML. It has very specific rules for encoding HTML. If you're generating it, I'd recommend using an xml library to write the node containing HTML, to be sure you get the encoding right.

    HTMLencode will only perform the escaping necessary for embedding data within HTML, XML rules are more strict.

    0 讨论(0)
  • 2021-01-20 22:23

    Since RSS is XML, you might want to check out CDATA, which I believe is valid in the various RSS specs.

    <summary><![CDATA[Data Here]]>

    Here's the w3schools entry on it: http://www.w3schools.com/XML/xml_cdata.asp

    0 讨论(0)
  • 2021-01-20 22:23

    Instead of writing your own RSS XML feed, consider using the Django syndication framework from django.contrib.syndication:

    https://docs.djangoproject.com/en/dev/ref/contrib/syndication/

    It also supports enclosures, which is the RSS way for embedding images or video.

    For custom tags, there is also an lowlevel API which allows you to change the XML: https://docs.djangoproject.com/en/dev/ref/contrib/syndication/#the-low-level-framework

    0 讨论(0)
  • 2021-01-20 22:30

    Ive been using htmlentities/html_entity_decode but for some reason it doesnt work with the parser. In a normal test it works, but parser always returns html code without < > " characters.

    0 讨论(0)
  • 2021-01-20 22:40

    htmlencode/htmldecode should do the trick.

    0 讨论(0)
提交回复
热议问题