Parsing XML with JQuery\'s AJAX


/ Published in: jQuery
Save to your folder(s)

A snippet setup to grab an XML file, parse it, and return the data contained within.


Copy this code and paste it in your HTML
  1. jQuery.ajax({
  2. type: "GET",
  3. url: "dates.xml",
  4. dataType: "xml",
  5. success: function(xml) {
  6. jQuery(xml).find('date').each(function(){
  7. date = jQuery(this).find('value').text();
  8. var output = '<span class="date">'+date+'</span>';
  9. jQuery('body').append(jQuery(output));
  10. });
  11. }
  12. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.