So I am not really sure how to do this and it seems pretty pretty trivial but I am getting an rss feed back and all I want to do is loop through a set of each elements that have children but I cannot seem to figure out how to get the values. My xml looks like this:
<rss>
<item>
<title>Test</title>
<picture>Test</picture>
</item>
<item>
<title>Test 1</title>
<picture>Test 1</picture>
</item>
</rss>
My jquery looks like this:
$(document).ready(function() {
var FEED_URL = "myFeedUrl";
$.ajax({
url : FEED_URL,
type : "GET",
success : function(xml) {
var item = $(xml).find('item').children();
$(item).children().each(function() {
var title = $(item).children().find('title').text();
//do something
});
}
});
});
I am able to loop through it and get the ‘item’ element. But I want to loop through the children elements but I am not sure how to get the actual value! I thought I could do find such as:
var title = $(item).children().find('title').text();
But that doesn’t seem to work.
This should do it.