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