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:
$(document).ready(function(){ $.ajax({ url: 'file.rss', dataType: "xml", success: parseXML, error: function(){alert("Error: Something is wrong");} }); function parseXML(document){ $(document).find('item').each(function(){ var title = item.find('title').text(); var author = item.find('author').text(); var description = item.find('description').text(); 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.
No comments:
Post a Comment