3
如何使用jQuery读取和签署XML数据(不同大小的数组)?从XML中读取Ajax中未知大小的数组
AJAX从XML读取线节点并存储在javascript数组中,在XML数组中大小不是恒定的。
我的代码:
$(document).ready(function(){
$.ajax({
type: "GET",
url: "sites.xml",
dataType: "xml",
success: function(xml) {
$(xml).find('msg').each(function() {
var title = $(this).find('title').text();
i = 0;
tic = new Array();
$(this).find('desc').each(function() {
tic.push($(this).find('line').text());
alert(tic[i]);
i++;
});
});
}
});
});
和XML文件(演示)
<msgs>
<msg>
<title>ABC</title>
<desc>
<line>test 1</line>
<line>test 2</line>
<line>test 2</line>
</desc>
<time>5</time>
</msg>
</msgs>
有人可以帮我请
您可以添加更多关于如何签名的信息吗?也许预期输出的一个例子 – ManseUK