Search code examples
phprsssimple-html-dom

How can I parse RSS description tag with PHP


I'm looking for an easy way to parse through RSS description tags in order to store img links as well as any text displayed.

I'm using Last RSS in order to parse the RSS feeds, however, the description tags have a lot of various information for each feed and they all vary greatly.

Currently I'm using the Simple HTML Dom Parser to grab the img links from the description, however, this does not seem to work for all feeds. For instance it does not recognize the img in the following description from dribbble:

<![CDATA[<a height="150" href="http://dribbble.com/shots/1405514-sparrows" width="200"><img alt="sparrows" height="600" src="http://d13yacurqjgara.cloudfront.net/users/14152/screenshots/1405514/sparrows.jpg" width="800" /></a><p>We are currently working on identity for a new Canadian project called "sparrows". A place for creatives to gather some useful readings.</p>]]>

What is the best way to obtain this information?


Solution

  • I used LastRSS built in function to strip out the CDATA tags and keep the rest of the html attributes in tact.

    This is done simply as follows:

    // Create lastRSS object
    $rss = new lastRSS;
    
    $rss->CDATA = 'content';