Read xml file without knowing tag name

0

Good morning, my friend,

I need to read an xml file (NF-e) where they have several items, however in each item there may be a different tag. In this case they would be in tax tags, where the ICMS tag can have multiple names (ICMS00, ICMS02, ICMS100 ..), and I need to read the tags they have inside.

XML example: link

The code I'm using and trying to read this is:

$link = "importacoes/1-42180984431352000191550010001174881191386794.xml"; //link do arquivo xml

$xml = simplexml_load_file($link);

echo $xml->NFe->infNFe->ide->cUF;

foreach($xml->NFe->infNFe->det as $itemm){
    echo '<br>';echo '<br>';
    echo $itemm->prod->cProd;
    echo '<br>';
    echo $itemm->prod->xProd;
    echo '<br>';
    $icms = $itemm->imposto->ICMS;

    print_r($icms);
    echo (string)$icms->ICMS;
}
    
asked by anonymous 08.10.2018 / 13:09

0 answers