如何使用jquery显示xml atribute (在zRSSFeed脚本中)

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

本文关键字:zRSSFeed 脚本 atribute 何使用 jquery 显示 xml      更新时间:2023-09-26

这是来自 RSS 提要的 xml 文件片段

<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>

现在这是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 +'>'

现在,我不想获取entry.decription而是获取entry.decription内的src值我试过: entry.decription[src]entry.decription[src].val()entry.decription->src entry.decription.attr(src)entry.decription.getAtrribute("src")(我可能在这里错误地输入了任何这些代码 - 但是当我尝试它们时,我确实在谷歌中检查了"getAttribute"之类的东西),但它们都不起作用。

试试这个。

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

然后将位于锚标记中的条目描述替换为 src。

尝试

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