Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Bom dia,
Galera estou com um duvida aqui, tenho um código em php que faz a leitura de uma XML e no final ele me devolve apenas os campos que eu preciso, porem eu precisaria que ele lê-se mais de uma arquivo XML. Será que alguém pode me dar uma luz ?
Segue o código atual:
<?php
ini_set('default_charset', 'UTF-8');
$xml = simplexml_load_file('*.xml');
echo 'NF-e N.<br>';
echo substr ($xml->NFe->infNFe->cobr->fat->nFat,0, 10).'<br>';
echo 'CNPJ <br>';
echo $xml->NFe->infNFe->dest->CNPJ.'<br>';
echo 'Incricao Estadual<br>';
echo $xml->NFe->infNFe->dest->IE.'<br>';
echo 'Nome <br>';
echo $xml->NFe->infNFe->dest->xNome.'<br>';
echo 'Endereco <br>';
echo $xml->NFe->infNFe->dest->enderDest->xLgr.', ';
echo $xml->NFe->infNFe->dest->enderDest->nro.'<br>';
echo 'Bairro<br>';
echo $xml->NFe->infNFe->dest->enderDest->xBairro.'<br>';
echo 'Cidade<br>';
echo $xml->NFe->infNFe->dest->enderDest->xMun.' - ';
echo $xml->NFe->infNFe->dest->enderDest->UF.'<br>';
echo 'CEP<br>';
echo $xml->NFe->infNFe->dest->enderDest->CEP.'<br>';
echo 'Pais<br>';
echo $xml->NFe->infNFe->dest->enderDest->xPais.'<br>';
echo 'Telefone<br>';
echo $xml->NFe->infNFe->dest->enderDest->fone.'<br>';
?>
Agradeço desde já.Infelizmente não retornou esse erro.
Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "0123456789.xml" in C:\wamp\www\canhotos\canhoto.php on line 12
Bom dia, apenas dando uma resposta para quem procurar, esta aqui a solução uma galera no face acabou me ajudando...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sem título</title>
</head>
<body>
<?php
ini_set('default_charset', 'UTF-8');
echo "<table border=\"1\" width=\"750px\">";
echo "<td>Numero da Nota</td>";
echo "<td>Nome do Cliente</td>";
{
echo "<tr>";
foreach(glob('xml/*.xml') as $xmlFile){
$xml = simplexml_load_file($xmlFile);
echo "<td>".substr ($xml->NFe->infNFe->infAdic->infCpl,17,9).'</td>';
echo "<td>".$xml->NFe->infNFe->dest->xNome.'</td>';
echo "</tr>";
}
echo "</table>";
}
?>
</body>
</html>
Cara, tenta fazer o sequinte:
while ($arquivo = readdir($pasta)){
Se der certo me avisa.Falows