I have an XML file which is structured as follows:
<row>
<store>place1</store>
<location>location1</location>
</row>
<row>
<store>place2</store>
<location>location2</location>
</row>
<row>
<store>place3</store>
<location>location3</location>
</row>
These rows go up to 5000. Now I’ve got a JavaScript function which searches through the file, and based on what the user types returns the value from the XML file. At the moment it only searches through the store field and returns a value/series of values. How can I get it to search and then display both? So for example if I searched “location3” it would return both the store (in the example above this is ‘place3’) and also return the location (i.e. ‘location3’)?
So far I have 2 un-finished solutions:
1)I have managed to do this in JQuery like so:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "index.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('Row').each(function(){
var store = $(this).find('store').text();
var location = $(this).find('location').text();
$('<div class="items"></div>').html('<p class="items">Store: '+store+'</p><p class="items">Location: '+location+'</p>').appendTo('#page-wrap');
});
}
});
});
but it doesn’t work in IE6. Also, the above code just returns all the values whereas I need it to return values based on user input.
2)I have also done this in JavaScript, which I have pasted here. In this example I can return a result but it only searches the “store”!
As a MAJOR hurdle I need to support IE6 :/
Any help would be much appreciated.
this might be stupid but anyway. It does the trick