I have an RSS file, and I'm trying to use JQuery to read though the file and print the contents to an HTML page.
The RSS file looks like this:
<contents>
<item>
<title>Title</title>
<author>Author</author>
<description>Description</description>
</item>
<item>
<title>Title</title>
<author>Author</author>
<description>Description</description>
</item>
</contents>
My JQuery code so far looks like this and I SOLVED IT MYSELF, so cancel the question, and here's the solution:
$(document).ready(function(){
$.ajax({
url: 'file.rss',
dataType: "xml",
success: parseXML,
error: function(){alert("Error: Something is wrong");}
});
function parseXML(document){
$(document).find('content').each(function(){
$(this).find('item').each(function(){
var author = item.find('author').text();
var description = item.find('description').text();
var output = description + title + author;
$(#div).html(output);
But the output isn't what I want! I want the code to loop through every entry in the RSS feed and each entry out separately, like this:
Title, Author
Description
Title, Author
Description
Instead, what's happening is that I'm getting all the titles and authors together, like this:
Title, Title
Author, Author
Description, Description
I am not sure what I'm doing wrong.