Quantcast
Channel: Extracting images from RSS/Atom feeds - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Ed. for Extracting images from RSS/Atom feeds

$
0
0

Using these sources:

It is essential that you get your content correctly as XML, by setting the dataType to 'xml'.

This code is self-contained and works:

var xmlString = '<Customer><![CDATA[ <img src="y1" /> ]]></Customer>';var xmlObj = $.parseXML(xmlString);var cdataText = xmlObj.firstChild.firstChild.textContent;var jqueryObj = $(cdataText);var imgUrl = jqueryObj.find('img').attr('src');console.log(imgUrl);

This is slightly imprecise because you don't give quite enough information to exactly reproduce your situation. I will start as though this from your question is the only part of your code:

if (feed_image_type == "description") {    item_img = $($(this).find('description').text()).find("img").attr("src");}

This ought to get close:

if (feed_image_type == "description") {    var cdataText = $(this).firstChild.firstChild.textContent;    var jqueryObj = $(cdataText);    item_img = jqueryObj.find('img').attr('src');}

Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>