this is the code for search..
in this xml file is in a different server.
function search() {
var xhr = new XMLHttpRequest();
var query = document.getElementById("searchText").value;
var regex = new RegExp(query,"i");
xhr.open("POST", "http://localhost:49989/WebService1.asmx/AllProduts", true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var doc = $.parseXML(xhr.responseText);
var $xmlresponsetree = $(doc);
var rows = "";
$xmlresponsetree.find("products").each(function () {
if ($(this).find("Productname").text().match(regex)) {
rows += "<tr><td>" + $(this).find("productid").text() + "</td>";
rows += "<td>" + $(this).find("Productname").text() + "</td>";
rows += "<td>" + $(this).find("Categoryname").text() + "</td>";
rows += "<td>" + $(this).find("Unitprice").text() + "</td>";
rows += "<td>" + $(this).find("Productdescription").text() + "</td>";
rows += "<td>" + $(this).find("Availablestock").text() + "</td></tr>";
}
})
document.getElementById('results').innerHTML = rows;
}
}
xhr.send();
}