Problem reading an XML with php

1

I have the following problem, when reading an xml of an invoice I am presented with a Warning with a specific invoice format. This is not happening to me with another group of invoices that I can process. Then I leave the Warning that is generating me.

Warning:

  

Warning: SimpleXMLElement :: __ construct ():   tmp / CAMF840207IB3-20180108T181935.xml: 20: namespace error:   xmlns: schemaLocation: ' link    link '   is not a valid URI in   /opt/lampp/htdocs/cajachica/models/archivo_model.php on line 75

Line 75 code

$xml = new SimpleXMLElement($path."/".$archivo,null,TRUE);

The line where the error is being generated is the following:

<cfdi:Complemento>
<registrofiscal:CFDIRegistroFiscal xmlns:schemaLocation="http://www.sat.gob.mx/registrofiscal http://www.sat.gob.mx/sitio_internet/cfd/cfdiregistrofiscal/cfdiregistrofiscal.xsd" Version="1.0" Folio="XXXXXXXXXXXX" xmlns:registrofiscal="http://www.sat.gob.mx/registrofiscal"></registrofiscal:CFDIRegistroFiscal>

The section of the code where I am registering the namespace :

 $xml->registerXPathNamespace('reg',$namespaces['registrofiscal']);
    
asked by Yoel Rodriguez 15.01.2018 в 20:45
source

2 answers

2

This worked for me to read the CFDIs that they bring in the add-on TaxRegistration: CFDIRegistroFiscal

    libxml_use_internal_errors(true);

    $xml= new \SimpleXMLElement($xml_file, null, true);
    
answered by 01.02.2018 / 21:17
source
1

It also helped me a lot to put the line

libxml_use_internal_errors(true); 
$xml= new \SimpleXMLElement($xmlname, null, true);

Since this happened to me with the CFDIs (that start with AAA) that these were stamped with a password, instead of FIEL. They refer to a page of the SAT that tries to access an object that can not be read by the server.

    
answered by 12.10.2018 в 04:05