title: How to AJAX load a blog image from RSS/XML when img is in CDATA
body: <p>How to AJAX load blog image from RSS/XML when img is in CDATA?</p>
  
  <p>I can load the title, url, publication date, etc... from our blog rss feed, but I cannot figure out how to target the image. I started with <a href="http://snipplr.com/view/50152/" rel="nofollow noreferrer">this</a> script and modified it to get this: </p>
  
  <pre><code>$.ajax({
  type: "GET",
  url: "http://www.example.com/blog/feed",
  dataType: "xml",
  
  success: function(xml) {
  
      var contain = $("div#blogSection");
      var limit = 1;
  
      $(xml).find('item').each(function(index){
      if( index &lt; limit ){
  
          var title = $(this).find('title').text();
          var url = $(this).find('link').text();
          var pubDate = $(this).find('pubDate').text();
          var img = $(this).find('content:encoded &gt; p &gt; img').attr('src').text();
          var desc = $(this).find('description &gt; p:first').text();
  
          $('&lt;div class="blogFeed"&gt;&lt;/div&gt;').html('&lt;div class="feedThumbnail"&gt;&lt;img src="'+img+'" class="resizable" title="blog image" alt="blog image"&gt;&lt;/div&gt;&lt;div class="feedExcerpt"&gt;&lt;h3 class="title"&gt;&lt;a href="'+url+'"&gt;'+title+'&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;'+desc+'&lt;/p&gt;&lt;p&gt;&lt;a class="allLink" href="'+url+'" title="read more" alt="read more" target="_blank"&gt;read more&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;').appendTo(contain);
          return;
          }
          });//end each
      }
  });
  </code></pre>
  
  <p>I think the problem is in CDATA within the xml, as I have read that it interprets everything within it as character data. The xml looks something like this:</p>
  
  <pre><code>&lt;item&gt;
      &lt;title&gt;Title&lt;/title&gt;
      &lt;link&gt;Link&lt;/link&gt;
      &lt;comments&gt;Comments&lt;/comments&gt;
      &lt;pubDate&gt;Date&lt;/pubDate&gt;
      &lt;description&gt;&lt;![CDATA[Description]]&gt;&lt;/description&gt;
      &lt;content:encoded&gt;&lt;![CDATA[&lt;p&gt;&lt;img src="http://www.example.com/img.jpg"...]]&gt;&lt;/content:encoded&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p>If I am correct that it is CDATA causing it to not target, what can I do in my ajax code to target the image and the first paragraph? If I am incorrect, should I add/remove?</p>
  
  <p>Thanks!</p>