aurel
aurel

Reputation: 3132

how to display xml atribute with jquery (within zRSSFeed script)

This is a snippet of the xml file from an RSS feed

<item>
<title>creamy whites</title>
<description>&lt;p&gt;&lt;a href="/pin/201606520789168653/"&gt;&lt;img 
src="http://media-cache.pinterest.com/upload/229261437250994034_0HxSxJNv_b.jpg"
&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;creamy whites&lt;/p&gt;</description>
</item>

Now this is the code that is already in the ZRRSfeed:

// Add feed row
html += '<li class="rssRow '+row+'">' + 
    '<'+ options.titletag +'><a href="'+ entry.link +'" title="'+          
        feeds.title +'" target="'+ options.linktarget +'">'
        + entry.description +'</a></'+ 
        options.titletag +'>'

Now instead of getting the entry.decription I would like to get the src value that is within the entry.decription I have tried: entry.decription[src], entry.decription[src].val(), entry.decription->src entry.decription.attr(src), entry.decription.getAtrribute("src") (i might have mis-typed any of this code here - but when I tried them I did check in google for things like 'getAttribute') and none of them worked.

Upvotes: 0

Views: 515

Answers (2)

rori
rori

Reputation: 43

try this one..

var src = $('entry.description')find('img').attr('src');

console.log(src); // debug using console firebug in firefox
//or developer tools in chrome
//the output should be the url of img

then replace entry.description that lies within anchor tag with src.

Upvotes: 1

Andreas Linden
Andreas Linden

Reputation: 12721

try

$(entry.description).find('img').attr('src')

Upvotes: 0

Related Questions