title: Grab image url from description in rss feed using php and simplexml
body: <p>I'm trying to set up a php page made up of images from 3 different RSS feeds, in 3 columns. The first feed is from a Wordpress blog, the second from an Etsy store, and the third from a Flickr feed.</p>
  
  <p>What I would like to do is grab the link to the images from the first 3 items in each feed.</p>
  
  <p>Relevant information:</p>
  
  <ul>
  <li>The Wordpress feed puts the link in the description, which is formatted as CDATA.</li>
  <li>The Etsy feed puts the image link as the first item in the description (E.g. <code>&amp;lt;img src=&amp;quot;http://ny-image2.etsy.com/il_155x125.126568958.jpg&amp;quot; /&amp;gt;</code>), but also has it in a <code>&lt;g:image_link&gt;</code> tag.</li>
  <li>The Flickr feed has the link in the description, but it comes third after links for the user's profile and a link to the photo page. There is also <code>&lt;media:content url="http://farm5.static.flickr.com/4016/4377189674_d6f3aafa81_m.jpg" 
  type="image/jpeg"
  height="159"
  width="240"/&gt;</code>.</li>
  </ul>
  
  <p>I've read over the basics of both php and simplexml but it seems what I'd like to do is too complicated for me to figure out on my own. I'd prefer to have a separate functions.php file so I only have to call the function on the web page.</p>
  
  <p>ETA:</p>
  
  <p>I've got the images for the Etsy feed pulled using</p>
  
  <blockquote>
    <p><code>&lt;?php<br>
    function getEtsyFeed($feed_url) {<br>
        $content = file_get_contents($feed_url);<br>
        $x = new SimpleXmlElement($content);<br>
        echo "&lt;ul&gt;";<br>
        foreach($x-&gt;channel-&gt;item as $entry) {<br>
            echo "<br>
            &lt;li&gt;<br>
              &lt;a href='$entry-&gt;link'&gt;&lt;img src=" . $entry-&gt;children('g', true)-&gt;image_link . " /&gt;&lt;/a&gt;<br>
            &lt;/li&gt;";<br>
            }<br>
        echo "&lt;/ul&gt;";<br>
    }<br>
    ?&gt;</code></p>
  </blockquote>
  
  <p>and the images from the Flickr feed pulled using</p>
  
  <blockquote>
    <p><code>&lt;?php<br>
    function getFlickrFeed($feed_url) {<br>
        $content = file_get_contents($feed_url);<br>
        $x = new SimpleXmlElement($content);<br>
        echo "&lt;ul&gt;";<br>
        foreach($x-&gt;channel-&gt;item as $entry) {<br>
            echo "<br>
            &lt;li&gt;<br>
              &lt;a href='$entry-&gt;link'&gt;&lt;img src=" . $entry-&gt;children('media', true)-&gt;thumbnail-&gt;attributes()-&gt;url . " /&gt;&lt;/a&gt;<br>
            &lt;/li&gt;";<br>
            }<br>
        echo "&lt;/ul&gt;";<br>
    }<br>
    ?&gt;</code></p>
  </blockquote>
  
  <p>I'm still not sure what to do about the blog feed, or how to only show the first 3 images without breaking the code that I do have.</p>