I'm in the process of parsing the rss feed from a tumblr blog onto my website. What I'm try to do is using jQuery to parse some specfic information from the feed. Here's a snippet below:
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="hub" href="http://tumblr.superfeedr.com/"/>
[lots of stuff]
</channel>
</rss>
Now, what I'd like to do is get href="http://tumblr.superfeedr.com/" from the feed since this will help me to confirm that the feed is actually from a tumblr blog.
The problem, however is that I'm a bit stuck with regards to how to do it. I've been trying to use the following:
$.get(blogUrl,
function(data) {
var xml = $(data);
var foo = xml.find('atom:link').attr('href');
alert("link href=" + foo);
});
Where blogUrl is the url of the rss feed in question. I've tried numerous variation on this - so many so that I've started going in circles - so I thought I'd ask here. I've tried changing 'atom:link' to 'atom\:link' and adding '.text()' to the end of the find command, but with no luck. I can also get the full text of the entire channel except for the atom:link data at the start, which is close but not right either!
So, how can I get the information that I'm after? All of the code guides and previous questions I've seen focus on iterating through multiple repeated items in an rss feed (which of course makes sense since that's what you're supposed to do with rss feeds), but I'm just trying to confirm the selected feed is the right type of feed that is expected.
Thanks!
UPDATE: Thanks to the help below from Jasd, I was able to get this working. Here's the updated code.
$.get(blogUrl,
function(data) {
var doc = data.getElementsByTagNameNS("http://www.w3.org/2005/Atom", "link")[0];
var href = dic.getAttribute("href");
}