can you get information with javascript of an xml loaded in input before passing it to the php language?

0

can you get information with javascript of an xml loaded in input before passing it to the php language? And if you can, how do you laugh? what I want is to extract the UUID from the xml and depending on the uuid send the variables to php

    
asked by Alejandro.C 28.06.2018 в 23:11
source

1 answer

1

first create your input type file, then you get the text by FileReader and then you show it, I'll give you an example

var fileChooser = document.getElementById('fileChooser');

function parseTextAsXml(text) {
    var parser = new DOMParser(),
        xmlDom = parser.parseFromString(text, "text/xml");

    //ahora, extraer los elementos del xmlDom y asignarlos a los imputs
}

function waitForTextReadComplete(reader) {
    reader.onloadend = function(event) {
        var text = event.target.result;

        parseTextAsXml(text);
    }
}

function handleFileSelection() {
    var file = fileChooser.files[0],
        reader = new FileReader();

    waitForTextReadComplete(reader);
    reader.readAsText(file);
}

fileChooser.addEventListener('change', handleFileSelection, false);
<input id="fileChooser" type="file">
    
answered by 29.06.2018 / 01:30
source