Home‎ > ‎

Processing XML with jQuery

posted 20 Jul 2011, 05:45 by Bevan Coleman
So easy :)

$.ajax({
  type: "GET",
  url: "books.xml",
  dataType: "xml",
  success: function(xml) {
    $(xml).find('record').each(function() {
      var uuid = $(this).find('uuid').text();
      var publisher= $(this).find('publisher').text();
      var rating = $(this).find('rating').text();
      var isbn = $(this).find('isbn').text();
      var title = $(this).find('title').text();
      var titleSort = $(this).find('title').attr('sort');
      var authors = []; $(this).find('authors author').each(function() { 
        authors.push($(this).text()) 
      }); 
      var tags = []; $(this).find('tags tag').each(function() { 
        tags.push($(this).text()) 
      }); 
      var comments = $(this).find('comments').text();
      var series = $(this).find('series').text();
      var seriesIndex = $(this).find('series').attr('index');
      ...
      ...
    });
  }
});
Comments