]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
read xml file with first attribute
authorBastian Dehn <hhaalo@arcor.de>
Sun, 23 Jun 2024 13:47:19 +0000 (15:47 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 23 Jun 2024 13:47:19 +0000 (15:47 +0200)
src/xmlviewer/viewer.html [new file with mode: 0644]

diff --git a/src/xmlviewer/viewer.html b/src/xmlviewer/viewer.html
new file mode 100644 (file)
index 0000000..f9ba487
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html lang="de">
+       <head>
+               <title>Zeitkonto</title>
+               <meta charset="UTF-8"> 
+               <meta name="viewport" content="width=device-width, initial-scale=1.0">
+       </head>
+       <body>
+               <main>
+                       <script>
+                               function loadFile() {
+                                       const fileinput = document.getElementById("filepath");
+                                       const element = document.getElementById("content");
+                                       const filereader = new FileReader();
+                                       filereader.onload = data => {
+                                               const parser = new DOMParser();
+                                               const xmldoc = parser.parseFromString(data.target.result, "text/xml");
+                                               console.debug(xmldoc.children[0].getAttribute("anfangssaldo"));
+                                               const divElement = document.createElement("div");
+                                               divElement.innerText = xmldoc.children[0].getAttribute("anfangssaldo");
+                                               element.append(divElement);
+                                       };
+                                       filereader.readAsText(fileinput.files[0]);
+                               }
+                       </script>
+                       <input type="file" id="filepath">
+                       <button onclick="loadFile()">Lade Datei</button>
+                       <div id="content"></div>
+               </main>
+       </body>
+</html>
\ No newline at end of file