in Education by
I have an XML file which is structured as follows: place1 location1 place2 location2 place3 location3 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(); $('
').html('

Store: '+store+'

Location: '+location+'

').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. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
this might be stupid but anyway. It does the trick function getItemByStore(store) { var matches = data.match(new RegExp("(" + store + "){1}(?:[\r\n\t ]+)(.*)", "m")); if (matches) { return [/*Store*/matches[1], /*Location*/matches[2]]; } return false; }

Related questions

0 votes
    This is a sample (edited slightly, but you get the idea) of my XML file: Test 192.168.1.1 Test ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    Background: I have an old web CMS that stored content in XML files, one XML file per page. I am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    You are working with this XML code snippet from the XML document cars.xml. You need to return the information about the cars ... D.doc("cars.xml")/cars/car[integer(year) > 2000]...
asked Mar 10, 2023 in Technology by JackTerrance
0 votes
    So the idea is that users can create collections with many pairs of words in it. For example, they ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I am trying to return an javascript value with Awesome lib in Vb.net / C#. Now I know how to ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I have an integer field person_id with the default value of NULL. I am using a stored procedure and ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 25, 2022 in Education by JackTerrance
0 votes
    Would you recommend that users go through the guest user request process to allow them to share a file from SharePoint with an external person?...
asked Mar 10, 2021 in Technology by JackTerrance
0 votes
    I have csv file and that looks like following. I want to remove all rows before one row values [ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    Inno Setup is a nice easy to use installer. It is rated high in this stackoverflow question. I have ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    Parameterized stored procedures are compiled after the user input is added. (1)True (2)False...
asked May 17, 2021 in General by JackTerrance
0 votes
    how can i create a script in which i can search someone number and it will provide me name, country, email ... an excel file format Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    I have the dataset that has the no_employees column that is the str object. whats is a best way to create the new ... 1-5 |Very Small Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I am currently exploring powershell. I like the way I can mount everything, for example the registry, so ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    I have minified all my js files using require, but require created a minified js file( main.min.js ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
...