I need to get the complete contents of an XML file to insert it into the database. I've tried fopen but it removes the tags, and with simplexml_load_file returns array.
$ponteiro = fopen ($arquivo,"r");
while (!feof ($ponteiro)) {
$linha = fgets($ponteiro);
echo $linha."<br>";
}
fclose ($ponteiro);
So it returns only the content in text without the tags. Example of a complete XML part:
<?xml version="1.0" encoding="UTF-8"?>
<nfeProc versao="3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
<NFe xmlns="http://www.portalfiscal.inf.br/nfe">
<infNFe versao="3.10" Id="NFe3516............">
<ide>
<cUF>35</cUF>
<cNF>00001623</cNF>
<natOp>VENDA DE MERCADORIA</natOp>
<indPag>1</indPag>
<mod>55</mod>
<serie>1</serie>
<nNF>1023</nNF>
<dhEmi>2016-09-02T19:57:00-03:00</dhEmi>
<dhSaiEnt>2016-09-05T19:57:00-03:00</dhSaiEnt>
<tpNF>1</tpNF>
<idDest>1</idDest>
<cMunFG>3530607</cMunFG>
I need to read an XML file from a folder and save it to MYSQL