Hi I am new to Jquery and struggling with parsing XML. I have a search box in my form that returns the results of a sql search when the user has entered the first few letters . this string is then searched with a php file and the results are returned in the form of an xml file. The problem is that I need to uniquely identify each name and id returned and then to be able to access a specific name/id set. so that this one item is shown on my form. The code (I thought) would return a list of all the the names but this seems to be in just one string. Can anybody please help me with accessing individual xml elements . I have included the xml file at the bottom , thanks for any help
// JQ - ajax
$(document).ready(function(){
$.ajax({
type: "GET",
url: "search_action.php?" + string ,
dataType: "xml",
success: disxml ,
});
})
}
function disxml(data){
$(data).find('results').each(function() {
var name = $(this).find('name').text();
var cus_id = $(this).find('id').text();
})
The XML File
<results>
<name>
The porter grp
</name>
<id>
548930
</id>
<name>
ADI UK
</name>
<id>
986565
</id>
<name>
Fireled
</name>
<id>
549899
</id>
<name>
JCK Rec LTD
</name>
<id>
548442
</id>
</results>