I am able to read my local .xml file with this code. My question is, is it possible to get certain xml element if all my elements have unique id (as child nodes) without looping the whole xml file? for example, get name and year of item with id=3.
$.ajax({
type: "GET",
url: "Cars.xml",
dataType: "xml",
success: getDataFromXml
});
function getDataFromXml(xml){
$(xml).find("Car").each(function(){
....
}
XML
<Cars>
<Car>
<Id>1</Id>
<Name>Tornado</Name>
<Model>Ferrari</Model>
<Year>1943</Year>
</Car>
<Car>
<Id>2</Id>
<Name>Tiger</Name>
<Model>Ferrari</Model>
<Year>1943</Year>
</Car>
<Car>
<Id>3</Id>
<Name>Cat</Name>
<Model>Ferrari</Model>
<Year>1943</Year>
</Car>
</Cars>