开发者

Parsing using mrss

I'm trying to parse an mrss feed using jquery but am having some difficulty targeti开发者_如何转开发ng the child element.

Code:

$(xml).find("item").each(function(){
   var $item = $(this);
   alert($item.find("media\\:thumbnail").text();
});

MRSS Structure:

<media:thumbnail url="http://somewebsite.com/someimage.jpg" />

UPDATE The solution $item.find("media\:thumbnail").attr("url") works very well in Firefox but running the code in Chrome reveals an undefined value. Can someone suggest a workaround.

Thanks


You're trying to display the text() of your found nodes. The example node you include has no text at all. You want the value of the url attribute:

$(xml).find("item").each(function(){
    var $item = $(this);
    alert($item.find("media\\:thumbnail").attr("url"));
});

If your media:thumbnail element had something between opening and closing tags you could use text() (and you still wouldn't be getting the url value):

<media:thumbnail url="http://somesite.com/simeimage.jpg">Some text string</media:thumbnail>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜