The item element is not a part of the media namespace, so getElementsByTagNameNS won't return it when you try to find it there. Try using getElementsByTagName for the tags that don't have media: in front of their names, and getElementsByTagNameNS for the ones that do.
Jeremy R. Geerdes Effective website design & development Des Moines, IA For more information or a project quote: http://jgeerdes.home.mchsi.com http://jgeerdes.blogspot.com http://jgeerdes.wordpress.com [email protected] Unless otherwise noted, any price quotes contained within this communication are given in US dollars. If you're in the Des Moines, IA, area, check out Debra Heights Wesleyan Church! And check out my blog, Adventures in Web Development, at http://jgeerdes.blogspot.com ! On Mar 23, 2009, at 11:25 PM, BjP wrote: > > Hello, > > Ive tried to switch this over to use getElementsByTagNameNS but the > number of entries always comes up as 0 but when I use the simple > implementation I get my 6 items; > > var items = google.feeds.getElementsByTagNameNS(result.xmlDocument, > "http://search.yahoo.com/mrss/", "item"); > > returns an items.length=0 > > var items = result.xmlDocument.getElementsByTagName('item'); > > gives items.length=6 for feed(as Ive requested only 6 items; > > http://publish.vx.roo.com/g6publish/common/playlist/rssgeneratorportal.aspx?SiteId=cb519624-44a2-4bf7-808b-3514d34e96e4&Format=flash&v=3&thumbnailtypecode=wide_small&channel=Latest+Videos&rsstype=mrss > > Is this feed format supported? > > Regards, > BjP > > On Mar 24, 1:14 pm, BjP <[email protected]> wrote: >> Thanks Jeremy, I'll give this a shot with the >> getElementsByTagNameNS. Was looking at this earlier and wasnt sure >> if >> I needed it or not. >> >> Kind Regards, >> BjP >> >> On Mar 23, 9:43 pm, Jeremy Geerdes <[email protected]> wrote: >> >>> Instead of getElementsByTagName('media:thumbnail'), you need to use >>> getElementsByTagNameNS(). The reason for this is that the tagName >>> for >>> the element you're looking for is really just "thumbnail." "media" >>> represents the namespace in which the browser will find the tag's >>> definition. For the sake of cross-browser compatibility, you'll >>> probably want to use the getElementsByTagNameNS included in the >>> Feeds >>> API. Its usage is outlined in the documentation at the link below: >> >>> http://code.google.com/apis/ajaxfeeds/documentation/reference.html#ge >>> ... >> >>> Jeremy R. Geerdes >>> Effective website design & development >>> Des Moines, IA >> >>> For more information or a project quote:http://jgeerdes.home.mchsi.comhttp >>> ://jgeerdes.blogspot.comhttp://jgee... >>> [email protected] >> >>> Unless otherwise noted, any price quotes contained within this >>> communication are given in US dollars. >> >>> If you're in the Des Moines, IA, area, check out Debra Heights >>> Wesleyan Church! >> >>> And check out my blog, Adventures in Web Development, >>> athttp://jgeerdes.blogspot.com >>> ! >> >>> On Mar 23, 2009, at 12:35 AM, BjP wrote: >> >>>> Hello, >> >>>> Im adapting a MRSS feed to display some of the latest videos >>>> added to >>>> the feed on my company sites; >> >>>> http://publish.vx.roo.com/g6publish/common/playlist/rssgeneratorporta >>>> ... >> >>>> The code Ive constructed has been a simple copy of one of the XML >>>> examples with some simple additions of jquery to render the result. >> >>>> However Ive found that in Firefox 2 and also Chrome I am unable >>>> to get >>>> the url attribute value of the media:thumbnail node with the error >> >>>> item.getElementsByTagName("media:thumbnail")[0] has no properties >> >>>> appearing in Firebug. >> >>>> The code I am using for the feedloaded section; >> >>>> function feedLoaded(result) { >>>> if (!result.error) { >>>> // Get all items returned. >>>> var items = result.xmlDocument.getElementsByTagName('item'); >>>> //clear out results div. >>>> $(".video<%inf_pageid%>").empty(); >>>> $(".video<%inf_pageid%>").append('<h3>Latest Videos</h3>'); >>>> // Loop through our items >>>> for (var i = 0; i < items.length; i++) { >>>> var item = items[i]; >>>> // Get the title from the element. firstChild is the text >>>> node >>>> containing >>>> // the title, and nodeValue returns the value of it. >>>> var title = item.getElementsByTagName("title") >>>> [0].firstChild.nodeValue; >>>> var link = item.getElementsByTagName("link") >>>> [0].firstChild.nodeValue; >>>> var descript= item.getElementsByTagName("description") >>>> [0].firstChild.nodeValue; >>>> //var temp= item.getElementsByTagName("media:thumbnail")[0]; >>>> //alert(temp); >>>> //var thumb = temp.attributes.getNamedItem("url").value; >>>> var thumb = item.getElementsByTagName("media:thumbnail") >>>> [0].getAttribute("url"); >>>> //alert(ff2); >>>> //create html string of complete listing >>>> var html = '<div class="item"><div class="preview-image"><a >>>> title="' + title + '" href="'+ link + '"><img alt="' + title + ' >>>> image" width="128" height="72" src="' + thumb + '"/></a></div><h4 >>>> width="20"><a title="' + title + '" href="' + link + '">' + title + >>>> '</ >>>> a></h4><div class="text">' + descript + '</div></div>'; >>>> //clear and append the output of string to video div >>>> $(".video<%inf_pageid%>").append(html); >>>> } >>>> } >>>> } >> >>>> Any ideas why this doesnt work in FF2 or Chrome? >> >>>> Thanks in advance, >>>> BjP > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google AJAX APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-AJAX-Search-API?hl=en -~----------~----~----~----~------~----~------~--~---
