Search XML File using Jquery

Exchange

New Member
I am currently trying to use jquery to search an XML File, I know how to do it for json, but I I am not familiar with the Jquery ajax api and wanted to know how I would do it for an xml file. This is the code to grab data and displayed it using json: \[code\] $('#search').keyup(function() {var searchField = $('#search').val();var myExp = new RegExp(searchField, "i");$.getJSON('data.json', function(data) { var output = '<ul class="searchresults">'; $.each(data, function(key, val) { if ((val.name.search(myExp) != -1) || (val.bio.search(myExp) != -1)) { output += '<li>'; output += '<h2>'+ val.name +'</h2>'; output += '<img src="http://stackoverflow.com/questions/15665303/images/'+ val.shortname +'_tn.jpg" alt="'+val.name +'" />'; output += '<p>'+ val.bio +'</p>'; output += '</li>'; } }); output += '</ul>'; $('#update').html(output);}); //get JSON });\[/code\]
 
Back
Top