我有这样的代码来加载 XML 文件的内容:
$.ajax({
type: "GET",
url: "SITESETUP_000003.XML",
dataType: "xml",
success: function (siteSetupRedemptionsRec) {
var sitesetup = "<table><thead><th>REDEMPTIONS Redemption ID</th><th>REDEMPTIONS Name</th><th>REDEMPTIONS Item Id</th><th>REDEMPTIONS Amount</th><th>REDEMPTIONS Department</th><th>REDEMPTIONS Subdepartment</th></thead>";
$(siteSetupRedemptionsRec).find('Redemptions').each(function () {
var redemptionId = $(this).find('RedemptionID').text();
var name = $(this).find('Name').text();
var itemId = $(this).find('ItemID').text();
var amount = $(this).find('Amount').text();
var dept = $(this).find('Department').text();
var subDept = $(this).find('Subdepartment').text();
sitesetup += "<tr>";
sitesetup += "<td>" + redemptionId + "</td>";
sitesetup += "<td>" + name + "</td>";
sitesetup += "<td>" + itemId + "</td>";
sitesetup += "<td>" + amount + "</td>";
sitesetup += "<td>" + dept + "</td>";
sitesetup += "<td>" + subDept + "</td>";
sitesetup += "</tr>";
});
sitesetup += "</table>";
$('#Site_Setup3').append(sitesetup);
},
error: function (xhr) {
alert(xhr.status);
}
});
如何按特定元素或列排序/排序?比如名字?