Cant get description rss tag data with javascript
Posted
by AdamB
on Stack Overflow
See other posts from Stack Overflow
or by AdamB
Published on 2009-08-05T23:35:24Z
Indexed on
2010/05/25
11:01 UTC
Read the original article
Hit count: 280
I'm currently making a widget to take and display items from a feed. I have this working for the most part, but for some reason the data within the tag within the item comes back as empty, but I get the data in the and tags no problem.
feed
is and xmlhttp.responseXML
object.
var items = feed.getElementsByTagName("item");
for (var i=0; i<10; i++){
container = document.getElementById('list');
new_element = document.createElement('li');
title = items[i].getElementsByTagName("title")[0].firstChild.nodeValue;
link = items[i].getElementsByTagName("link")[0].firstChild.nodeValue;
alert(items[i].getElementsByTagName("description")[0].firstChild.nodeValue);
new_element.innerHTML = "<a href=\""+link+"\">"+title+"</a> ";
container.insertBefore(new_element, container.firstChild);
}
I have no idea why it wouldn't be working for the tag and would be for the other tags.
Here is an example of the rss feed its trying to parse:
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>A title</title>
<link>http://linksomehwere</link>
<description>The title of the feed</description>
<language>en-us</language>
<item>
<pubDate>Fri, 10 Jul 2009 11:34:49 -0500</pubDate>
<title>Awesome Title</title>
<link>http://link/to/thing</link>
<guid>http://link/to/thing</guid>
<description>
<![CDATA[
<p>some html crap</p>
blah blah balh
]]> </description>
</item>
</channel>
</rss>
© Stack Overflow or respective owner