Created
April 5, 2018 16:18
-
-
Save josejailton/480a6e4f5b37fe506901ed56992ee67f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$model['sefaz'] = array(); | |
$array_sefaz_0 = array(); | |
$tabelas = $dom->getElementsByTagName('table'); | |
foreach($tabelas as $node){ | |
if($node->nodeName=='table' && $node->getAttribute('class')=='toggle box' OR $node->getAttribute('class')=='toggable box'){ | |
if($node->getAttribute('class')=='toggle box'){ | |
foreach($node->childNodes as $child){ | |
$cols = $child->getElementsByTagName('td'); | |
$array_sefaz_0['numero_item'] = (int)$cols->item(0)->nodeValue; | |
$array_sefaz_0['nome_produto'] = $cols->item(1)->nodeValue; | |
$array_sefaz_0['quantidade'] = $cols->item(2)->nodeValue; | |
$array_sefaz_0['unidade'] = $cols->item(3)->nodeValue; | |
} | |
}else{ | |
if($node->getAttribute('class')=='toggable box'){ | |
foreach($node->childNodes as $chil){ | |
$cols = $chil->getElementsByTagName('span'); | |
$array_sefaz_0['codigo_cadastro_fabricante'] = $cols->item(0)->nodeValue; | |
$array_sefaz_0['ncm'] = $cols->item(1)->nodeValue; | |
$array_sefaz_0['cfop'] = $cols->item(4)->nodeValue; | |
$array_sefaz_0['ean'] = $cols->item(10)->nodeValue; | |
$array_sefaz_0['embalagem'] = $cols->item(11)->nodeValue; | |
$array_sefaz_0['quantidade'] = $cols->item(12)->nodeValue; | |
$array_sefaz_0['preco_unitario'] = $cols->item(16)->nodeValue; | |
$array_sefaz_0['ipi_valor'] = $cols->item(36)->nodeValue; | |
$array_sefaz_0['ipi_percentual'] = $cols->item(38)->nodeValue; | |
} | |
} | |
} | |
array_push($model['sefaz'],$array_sefaz_0); | |
} | |
} | |
header('Content-Type: application/json'); | |
$jsonData = json_encode($model,JSON_PRETTY_PRINT); | |
echo $jsonData; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment