Menu

Javascript in XML File

0 Comment

JavaScript is used to extract information from both sources and match.
According to the criteria specified by a user, data for a device stored in the XML file can be retrieved.The criterion includes the id, location, manufacturer and year of purchase. The user can provide these criteria through input elements of a webpage i.e. through text boxes and dropdown lists. In case of textbox the user types the specific detail, while in case of a drop-down, the user selects from the available options.
Every textbox and the drop-down element has an id through which it can be accessed. So after selecting or typing in the search detail, once the user clicks the ‘submit’ button, the value typed or selected by the user can be retrieved through JavaScript by referring to the respective id. The value extracted is then compared with the corresponding detail associated to every device listed in the XML file by parsing the respective tags. All devices matching with the provided criterion are then listed.
There are several issues related to the use of text boxes as the input method for extracting the search criterion from the user. With text boxes, as the detail has to be typed in by the user there is room for spelling mistakes. In case of misspelled input, the search does not provide correct match results.
Secondly, it could be that a particular detail provided by the user does not exist in the database e.g. the user types detail for the manufacturer as Nvidia whereas Nvidia does not exist in the database. Therefore, with text boxes, the user has no idea of the options he/she has while providing search criterion.
With the use of dropdown lists, these issues can be overcome. Since the data for a particular search criterion is listed in the list to choose from, there is no room for spelling mistakes. Furthermore, the option selected is always present in the database. In fact, the dropdown list can be dynamically populated by referring to a particular tag of the XML database file.