xml 文件:-
<countries>
<country code='af' phoneCode='93' name='Afghanistan' />
<country code='al' phoneCode='355' name='Albania' />
<country code='dz' phoneCode='213' name='Algeria' />
<country code='ad' phoneCode='376' name='Andorra' />
<country code='ao' phoneCode='244' name='Angola' />
<country code='aq' phoneCode='672' name='Antarctica' />
<country code='ar' phoneCode='54' name='Argentina' />
<country code='am' phoneCode='374' name='Armenia' />
<country code='aw' phoneCode='297' name='India' />
<country code='au' phoneCode='61' name='Australia' />
</countries>
这是我的 JavaScript ajax:-
<script>
var getr='';
var ind= "India";
var getre;
function cli(){
$.ajax({
url: 'country_code.xml',
type:"get",
async: false,
success: function(xml) {
var result = $(xml).find("countries").each(function(){
getr = $(this).find("country").attr('name');
});
alert(getr);
},
error:function(){
alert('err');
}
});
}
</script>
在这里我想搜索属性India
。
我在上面尝试,但它首先给我我Afghanistan
该怎么做。
谢谢。