[ad_1]
Asked
Viewed
7 times
I have this xml file that shows a list of dates and the script that reads the file from top to bottom
Any way I start reading it from bottom to top? Or order it according to the numeric value dictated by the value inside the “DateTime” node?
I have the following code:
<?xml version="1.0" encoding="utf-8"?>
<QueueHistory>
<HistoryEntry>
<JobTitle>80791.cdr</JobTitle>
<JobID>PageB4DC</JobID>
<DateTime qualifier="Queued">
<Year>2022</Year>
<Month>6</Month>
<Day>7</Day>
<Hour>9</Hour>
<Minute>16</Minute>
<Seconds>17</Seconds>
</DateTime>
</HistoryEntry>
<HistoryEntry>
<JobTitle>80791.cdr 2</JobTitle>
<JobID>Page7ABE</JobID>
<DateTime qualifier="Queued">
<Year>2022</Year>
<Month>6</Month>
<Day>7</Day>
<Hour>9</Hour>
<Minute>19</Minute>
<Seconds>25</Seconds>
</DateTime>
</HistoryEntry>
</QueueHistory>
<script type="text/javascript">
function ExportToTable() {
var regex = /^([a-zA-Z0-9\s_\\.\-:])+(.history)$/;
//Checks whether the file is a valid xml file
if (regex.test($("#xmlfile").val().toLowerCase())) {
//Checks whether the browser supports HTML5
if (typeof(FileReader) != "undefined") {
var reader = new FileReader();
reader.onload = function(e) {
var xmlDoc = $.parseXML(e.target.result);
$(xmlDoc).find("HistoryEntry").each(function () {
var _name = $(this).find('JobTitle').text();
console.log(_name);
var _datestart = $(this).find('DateTime[qualifier="Queued"]> Year').text();
$("#someElement1").append('<tr><td>' + _name + '</td><td>' + _datestartm + "https://stackoverflow.com/" + _datestartmd + "https://stackoverflow.com/" + _datestart + ' '+_datestarth + ':'+_datestartminute + '</td></tr>');
});
var xmlrows = $(xmlDoc).find("HistoryEntry");
}
reader.readAsText($("#xmlfile")[0].files[0]);
} else {
alert("Sorry! Your browser does not support HTML5!");
}
} else {
alert("Please upload a valid XML file!");
}
}
</script>
Thank you for your help
default
[ad_2]