0

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.

Eric
  • 21
  • 3
  • 2
    You seem to have left out the part of the code that's creating the problematic output. Or any output. – Paul Roub Aug 20 '15 at 23:32
  • Aside from the missing code, this seems likely to be a duplicate question, check this answer http://stackoverflow.com/a/7067582/4258817 – Mousey Aug 20 '15 at 23:42
  • I've edited the code above for clarity. Mousey, thanks for the link -- unfortunately, it doesn't address my question. I've taken the steps suggested, but the output just isn't right. I'm having a tough time figuring out how to loop through the array of nodes, rather than looping through each individual node inside of . – Eric Aug 21 '15 at 01:27

0 Answers0