1
按日期排序返回的XML數據時遇到了很多麻煩。日期存儲爲YYYY-MM-DD。我正在努力尋找這種特定日期格式的在線幫助。使用jQuery按日期對XML結果進行排序
這是我的JS:
$(document).ready(function() {
$.ajax({
type: "GET",
url: "database.xml",
dataType: "xml",
success: function (xml) {
$(xml).find("event").filter(function() {
return $(this).find("eventplace").text() == 'NEWCASTLE';
}).each(function() {
var title = $(this).find('eventname').text();
var venue = $(this).find('eventvenue').text();
var city = $(this).find('eventplace').text();
var date = $(this).find('eventdate').text();
$('<div class="items">' + title + '</div>').html(title + venue + city + date).appendTo('#comingup');
});
}
});
});
,這裏是我的XML示例:
<Root_Element>
<eventserie>
<event>
<eventname>LITTLE COMETS</eventname>
<eventvenue>O2 ACADEMY</eventvenue>
<eventplace>NEWCASTLE</eventplace>
<eventdate>2014-02-21</eventvdate>
</event>
<event>
<eventname>SYMPHONIC PICTURES</eventname>
<eventvenue>THE CLUNY</eventvenue>
<eventplace>NEWCASTLE</eventplace>
<eventdate>2014-03-10</eventvdate>
</event>
<event>
<eventname>LET'S BUY HAPPINESS</eventname>
<eventvenue>THINK TANK</eventvenue>
<eventplace>NEWCASTLE</eventplace>
<eventdate>2014-02-10</eventvdate>
</event>
</eventserie></Root_Element>
添加解釋給你的答案,這將有助於p [人們理解。 –