-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
71 lines (53 loc) · 2.33 KB
/
script.js
File metadata and controls
71 lines (53 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
document.getElementById("filepicker").addEventListener("change", () => {
let output = document.getElementById("listing");
for (const file of event.target.files) {
let item = document.createElement("li");
item.textContent = file.webkitRelativePath;
output.appendChild(item);
loadXMLDoc(file.name);
};
}, false);
function loadXMLDoc(name) {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
// Request finished and response
// is ready and Status is "OK"
if (this.readyState == 4 && this.status == 200) {
empDetails(this);
}
};
// employee.xml is the external xml file
xmlhttp.open("GET", name, true);
xmlhttp.send();
}
function empDetails(xml) {
let i;
let xmlDoc = xml.responseXML;
let table = document.getElementById("id").innerHTML;
//Se extrae los datos de la factura
let x1 = xmlDoc.getElementsByTagName("cfdi:Comprobante");
let x2 = xmlDoc.getElementsByTagName("cfdi:Emisor");
let x3 = xmlDoc.getElementsByTagName("cfdi:Traslado");
//Se extrae los detalles de la factura
let x = xmlDoc.getElementsByTagName("cfdi:Concepto");
for (i = 0; i < x.length; i++) {
table += "<tr><td>" +
x1[0].getAttribute("Serie")+ " " +
x1[0].getAttribute("Folio")+ "</td><td>" +
x1[0].getAttribute("Fecha")+ "</td><td>" +
x2[0].getAttribute("Nombre")+ "</td><td>" +
x2[0].getAttribute("Rfc")+ "</td><td>" +
x1[0].getAttribute("TipoDeComprobante")+ "</td><td>" +
x[i].getAttribute("Descripcion")+ "</td><td>" +
x[i].getAttribute("Unidad") + "</td><td>" +
x[i].getAttribute("ClaveUnidad") + "</td><td>" +
x[i].getAttribute("Cantidad") + "</td><td>" +
x[i].getAttribute("NoIdentificacion") + "</td><td>" +
x[i].getAttribute("ClaveProdServ") + "</td><td>" +
x[i].getAttribute("ValorUnitario") + "</td><td>" +
x[i].getAttribute("Importe") + "</td><td>" +
x3[i].getAttribute("Importe") + "</td></tr>";
}
// Print the xml data in table form
document.getElementById("id").innerHTML = table;
}