我尝试使用JavaScript自动使XML元素过期。但是我的代码无法正确捕获到期日期。我该如何实现代码。
XML
<offer>
<cd expires="30/11/2018">
<head>Lorem ipsum dolor sit amet, consectetur adipiscing elit.1</head>
<image>https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Liliumbulbiferumflowertop.jpg/220px-Liliumbulbiferumflowertop.jpg</image>
</cd>
</offer>
JavaScript
.filter(function(offer) {
var today = new Date().setHours(0, 0, 0, 0);
var dateToBeMatchedString = offer["@_expires"];
if (!dateToBeMatchedString) return true;
var dateToBeMatched = new Date(
parseInt(dateToBeMatchedString.substring(6, 10)),
parseInt(dateToBeMatchedString.substring(3, 5)),
parseInt(dateToBeMatchedString.substring(0, 2))
);
return today <= dateToBeMatched;
});