I am working on a simple XML notebook to learn JQuery, and I can’t figure out how to do it: When a user types a contact’s name in a text box, I want to find the whole record of that person. XML looks like this:
<phonebook>
<person>
<number> 555-5555</number>
<first_name>Evelyn</first_name>
<last_name>Remington</last_name>
<address>Edge of the Abyss</address>
<image>path/to/image</image>
</person>
<person>
<number>+34 1 6444 333 2223230</number>
<first_name>Max</first_name>
<last_name>Muscle</last_name>
<address>Mining Belt</address>
<image>path/to/image</image>
</person>
</phonebook>
and the best I could do with jQuery is something like this:
var myXML;
function searchXML(){
$.ajax({
type:"GET",
url: "phonebook.xml",
dataType: "xml",
success: function(xml){myXML = $("xml").find("#firstNameBox").val())}
});
}
What I want to do is to return the entire element <person>so that I can iterate and display all the information of this person. Any help would be appreciated.
Nated source
share