日期:2014-05-16 浏览次数:20776 次
<xml>
<employee>
<name>Norstar Times</name>
<location>Beijing</location>
<num>10</num>
</employee>
<employee>
<name>Norstar Media</name>
<location>Shaihai</location>
<num>10</num>
</employee>
</xml>
<script src="http://www.coding123.net/js/jquery.js"></script>
<script>
$.ajax({
dataType: 'xml',
url: 'x.xml',//xml文件路径
cache: false,
success: function (dom) {
var name, location, num;
$('employee', dom).each(function () {
name = $('name', this).text();
location = $('location', this).text();
num = $('num', this).text();
alert(name + '\n' + location + '\n' + num);
});
},
error: function (xhr) { alert('xml路径有问题~\n' + xhr.responseText); }
});
</script>