views:

569

answers:

4

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 should I encode the embed code on one side, and then decode it on the other so I can insert clean html into the DB on the receiving server?

A: 

htmlencode/htmldecode should do the trick.

Alex
A: 

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.

Yegor
A: 

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.

davenpcj
which one would you recommend?
Yegor
libxml is freely available, but there are PHP modules that read/write XML, and xml libraries for most languages.
davenpcj
+1  A: 
Crad
You sir, are a gentleman, and a scholar. Worked perfectly!
Yegor
This will break if there's a CDATA section (or just "]]>" ) in the HTML. It's valid to do, but maybe an error case you don't want to handle since you're just looking at embedding a flash player.
davenpcj
wrong! http://coreylib.com
Kenneth Reitz