Read XML attribute

2

I'm reading an XML file with the command simplexml_load_file() which has the following structure:

<nfeProc xmlns="http://www.portalfiscal.inf.br/nfe" versao="2.00">
    <NFe></NFe>
</nfeProc>

How do I get the value of the versao attribute?

I tried the following code but it did not work

$xmlsimple=simplexml_load_file($_FILES['filexml']['tmp_name']);
echo $xmlsimple->nfeProc['versao'];
    
asked by anonymous 08.10.2015 / 16:02

1 answer

1

Try this:

echo $xmlsimple->attributes()['versao'];

Source: php.net

08.10.2015 / 16:14