1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to configure RSS feed to allow HTML

Discussion in 'XML & RSS' started by Tom_e_rock, Jul 8, 2006.

  1. #1
    I gota killer RSS feed, but it contains HTML.

    I need it to contain html to properly display on other sites.

    On top, what should I add.. Like addtype or something

    it wont validate for me.

    Thanks
     
    Tom_e_rock, Jul 8, 2006 IP
  2. dc dalton

    dc dalton Active Member

    Messages:
    521
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #2
    You have to convert the special characters to their character entities to get it to validate. I just built an RSS feed creator and had to add in things like this to covert them:

    
    $description = str_replace("&", "&", $description);
    
    $description = str_replace("<", "&lt;", $description);
    
    $description = str_replace(">", "&gt;", $description);
    PHP:
    ANY special character has to be done this way to get a valid xml file.
     
    dc dalton, Jul 8, 2006 IP
  3. Tom_e_rock

    Tom_e_rock Peon

    Messages:
    428
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #3
    omggoshh.. That suxx

    Whats the best alternative then, if I need my html table charts of information to be displayed on other sites, just like an RSS?

    Thanks
     
    Tom_e_rock, Jul 8, 2006 IP
  4. dc dalton

    dc dalton Active Member

    Messages:
    521
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    58
    #4
    HMM good question .... really without jumping through hoops the only way is rss, which means doing the above nonsense. Only other thing I can think of are images or PFD files and that's not a pretty thing either.
     
    dc dalton, Jul 8, 2006 IP
  5. Darrin

    Darrin Peon

    Messages:
    123
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Not sure if this will be helpful or just add to the frustration, but..

    ASP.NET has a some server side methods called 'HTMLEncode' and 'URLEncode' which will automatically convert all those characters for you. You can pass the whole string and it will convert all that are necessary.

    I havn't seen something like this in PHP or Perl, but I'm sure you are not the first to run into it. Chances are someone may have built a similar function if it hasn't been added to PHP already.
     
    Darrin, Jul 9, 2006 IP
  6. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #6
    Please note that RSS specifications, including RSS 2.0, doesn't allow embed HTML.
    I suggest you to use Atom 1.0 format that allows to include (X)HTML contents even whithout escaping it.
     
    weppos, Jul 10, 2006 IP
  7. Tom_e_rock

    Tom_e_rock Peon

    Messages:
    428
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I dont understand Xhtml and what it means.

    I know that RSS 2.0 you can add html, but it's not recommended as

    a) harder to get indexedf or the meta
    b) other parsers might have trouble recognizing it

    But it is allowed
     
    Tom_e_rock, Jul 10, 2006 IP
  8. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #8

    You need to encode it.
    If you use Atom you can add well formed XHTMl or HTML content inline without encoding it. :)
     
    weppos, Jul 10, 2006 IP
  9. GRex

    GRex Well-Known Member

    Messages:
    59
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    113
    #9
    Oh my god. I remember wasted a whole day figuring that out.

    It's a very simple solution, Tom_e_rock. All you need is CDATA within your tags. Google for it and you'll know what I mean.
     
    GRex, Jul 20, 2006 IP
  10. weppos

    weppos Well-Known Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    125
    #10
    CDATA is just the most simple way to hide parser junk rss content, it's not the right way to create a well formed feed. :)
     
    weppos, Jul 22, 2006 IP
  11. Kendothpro

    Kendothpro Well-Known Member

    Messages:
    574
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    120
    #11
    There's no need to use those functions, php already has a built-in function for the job
    In fact those 3 lines can be reduced to this:
    $description=htmlentities($description);
    PHP:
    Hope that helped ;)
     
    Kendothpro, Jul 28, 2006 IP
  12. netmaster123

    netmaster123 Well-Known Member

    Messages:
    1,852
    Likes Received:
    47
    Best Answers:
    0
    Trophy Points:
    140
    #12
    netmaster123, Aug 27, 2006 IP
  13. VestRite

    VestRite Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Dalton has a pretty good idea. What you can do to speed up the process is to copy and paste the document into a text file and "find and replace" all the brackets with their proper codes. Makes an hour job turn into a thirty second job.
     
    VestRite, Feb 10, 2008 IP
  14. lukazs

    lukazs Well-Known Member

    Messages:
    583
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    125
    #14
    lukazs, Feb 15, 2008 IP
  15. guitarbinge

    guitarbinge Peon

    Messages:
    208
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #15
    thanks for the tips ;)
     
    guitarbinge, Mar 6, 2008 IP
  16. dotWdot

    dotWdot Peon

    Messages:
    685
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #16
    pretty damn useful - trying to set up a collectables rss and getting nowhere - built my own parser but now I realise other people need to be able to use it..
     
    dotWdot, Mar 9, 2008 IP
  17. culzboyz

    culzboyz Guest

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    thanks......
     
    culzboyz, Mar 10, 2008 IP
  18. IndiaNets

    IndiaNets Guest

    Best Answers:
    0
    #18
    Quite useful informations about RSS feed.. I agree!
    But the difference b/w post #12 and #13 is exceptionally cool : 1 year 6 months almost. ;)

    Take it easy!
    Thanks
     
    IndiaNets, Mar 10, 2008 IP
  19. freestate

    freestate Well-Known Member

    Messages:
    975
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    160
    #19
    Thanks Dalton - nice tip!

    What's the difference between str_replace & ereg_replace in this instance?
     
    freestate, Mar 14, 2008 IP
  20. kewlchat

    kewlchat Well-Known Member

    Messages:
    1,779
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    110
    #20
    Nice tips very nice indeed.
     
    kewlchat, Mar 29, 2008 IP