Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Shelane French
Added: Jan 24, 2020 9:28 PM
Views: 6
Tags: jquery xml
  1. $.get('/onelab.xml', function(data) {
  2.     var $xml = $(data), output = '';
  3.     $xml.find("item").each(function() {
  4.         var $this = $(this),
  5.             item = {
  6.             title: $this.find("title").text(),
  7.             link: $this.find("link").text(),
  8.             description: $this.find("description").text(),
  9.             pubDate: $this.find("pubDate").text(),
  10.             author: $this.find("author").text()
  11.         }
  12.         output += '<p><a href="' + item.link + '">' + item.title + '</a><br />' + item.pubDate + ': ' + item.description + '</p>';
  13.     });
  14.     $('#latestnews').html(output);
  15. });