I am trying to read a binary file which contains data between Tags (xml style), and I using a page like this:
<!DOCTYPE html>
<html lang="en">
<body>
<header>
<h1>Load a File</h1>
</header>
<main>
<input type="file" id="file">
</main>
<script>
function onfilechange(evt) {
var selFile = evt.target.files[0];
var reader = new FileReader();
reader.onloadend = function (e) {
var h3d =new Int8Array(e.target.result);
console.log(h3d);
console.log(enc.decode(h3d));
};
reader.readAsArrayBuffer(selFile);
}
document.getElementById('file').addEventListener('change', onfilechange);
var enc = new TextDecoder("utf-8");
</script>
</body>
</html>
And I get this result for the file (first Console.log):
Int8Array(1025) [9, 0, 0, 0, 8, 60, 77, 79, 68, 69, 76, 79, 62, 9, 0, 0, 0, 8, 60, 80, 79, 78, 84, 79, 83, 62, 10, 0, 0, 0, 2, 0, 0, 0, 1, 65, 0, 0, 0, 0, 0, 0, 36, 64, 0, 0, 0, 0, 0, 0, 36, 64, 0, 0, 0, 0, 0, 0, 36, 64, 2, 0, 0, 0, 1, 66, 0, 0, 0, 0, 0, 0, 36, 64, 0, 0, 0, 0, 0, 0, 68, 64, 0, 0, 0, 0, 0, 0, 36, 64, 2, 0, 0, 0, 1, 67, 0, 0, 0, 0, …]
and second Console.log:
<MODEL>
<POINTS>A$@$@$@B$@D@$@CN@D@$@DN@$@$@EN@$@>@FN@D@>@GD@$@I@HD@D@I@
I$@$@I@J$@D@I@</POINTS>
<FACES>ABCDADEGIIGHJAIJBHGEFFEDCJHFCB</FACES>
<SYSTEM></SYSTEM>
</MODEL>
How can i get the actual data stored in between the tags? I Should be geting some points coordinates like:
<MODEL>
<POINTS>A,10,10,10; B,10,20,30; ...</POINTS>
<FACES>1,A,B,C,D; 2,A,D,E,G,I;... </FACES>
<SYSTEM>...and some other stuff!</SYSTEM>
</MODEL>
Thank you!