2

I'm trying to read anXML file using 'simplexml_load_file' and it works fine, except with one file that has these tags '',''. When I try to read this file, it fails like it was a blank file. Than I try to remove this character ':' and than it works...

Is there a better way to read this, without removing the ':' character?

here the XML

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Header>
        <nfeCabecMsg xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
            <cUF>43</cUF>
            <versaoDados>3.10</versaoDados>
        </nfeCabecMsg>
    </soap:Header>
    <soap:Body>
        <nfeAutorizacaoLoteResult xmlns="http://www.portalfiscal.inf.br/nfe/wsdl/NfeAutorizacao">
        <retEnviNFe xmlns="http://www.portalfiscal.inf.br/nfe" versao="3.10">
            <tpAmb>2</tpAmb>
            <verAplic></verAplic>
            <cStat>104</cStat>
            <xMotivo>Lote processado</xMotivo>
            <cUF>43</cUF>           
            <dhRecbto>2014-10-29T08:49:23-02:00</dhRecbto>
            <protNFe versao="3.10">
                <infProt>
                    <tpAmb>2</tpAmb>
                    <verAplic></verAplic>
                    <chNFe></chNFe>
                    <dhRecbto>2014-10-29T08:49:23-02:00</dhRecbto>
                    <nProt>143140001934763</nProt>
                    <digVal></digVal>
                    <cStat>100</cStat>
                    <xMotivo>Autorizado o uso da NF-e</xMotivo>
                </infProt>
             </protNFe>
        </retEnviNFe>
        </nfeAutorizacaoLoteResult>
    </soap:Body>
</soap:Envelope>
Naruto
  • 1,210
  • 3
  • 25
  • 28
Matheus Hernandes
  • 629
  • 1
  • 6
  • 25

2 Answers2

0

In an XML file you have to escape special chars. Otherwise your XML syntax is broken.

http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references

Other think perhaps the Request to fetch die XML is not in UTF-8.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
0

This is duplicate question.

Read answers here:

parse a SOAP XML response with Namespaces using PHP

Parse soap response using PHP

Community
  • 1
  • 1
Apul Gupta
  • 3,044
  • 3
  • 22
  • 30