I'm creating a stock input / output system using an XML file
To do this, I need to create a preview of the XML content that the user is uploading (as a table, just for the person to know if that is the same XML)
I'm developing in CodeIgniter, receiving the XML by the controller looks like this:
public function recebeXML(){
$arquivo = $_FILES['arquivo'];
$xml = simplexml_load_file($arquivo['tmp_name']);
$numProdutos = count(/*numero de produtos*/);
for($i = 0; $i<$numProdutos; $i++){
$produto = $xml->NFe->det[$i]->prod;
$dados[$i] = array(
"CodigoProduto" => (string)$produto->cProd,
"NomeProduto" => (string)$produto->xProd,
"Quantidade" => (string)$produto->uCom,
);
}
}
$this->entradaDados($dados);
}
The data is placed in the table by means of a foreach.
The question itself is: can you put the organized data into the user view without having to reload the page? I thought about creating a modal to appear after I uploaded, but how to put the files in there?