3
I am making a request in php via Curl, and in the reply this returning me an xml, but I can not work with this xml..
REQUISITION:
<br>
curl = curl_init('http://ws.targetmailing.com.br/consulta');<br>
curl_setopt($curl, CURLOPT_HEADER, false);<br>
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);<br>
curl_setopt($curl, CURLOPT_POST, true);<br>
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);<br>
$response = curl_exec($curl);<br>
curl_close($curl);
<br>
RETURN:
<?xml version="1.0" encoding="UTF-8"?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:resultado xmlns:ns2="http://ws.targetmailing.com.br/consulta" restricao="false" data="2016-04-29T07:42:59.456-03:00"><protocolo numero="1541656894" digito="9"/><operador codigo="1000" nome="INFOMAIL SERVICOS DE BANCO DE DADOS E INFORMATICA"/><consumidor><consumidor-pessoa-juridica data-fundacao="1990-01-01T00:00:00-03:00" nome-comercial="RAZÃO SOCIAL HOMOLOGAÇÃO" razao-social="A EMPRESA LTDA ME"><cnpj numero="74907134000142"/><endereco logradouro="R JOSÉ DA SILVA" numero="10" bairro="CENTRO" cep="01342000"><cidade nome="SÃO PAULO"><estado sigla-uf="SP"/></cidade></endereco></consumidor-pessoa-juridica></consumidor><spc><resumo quantidade-total="0"/></spc></ns2:resultado></S:Body></S:Envelope>
AS I AM TREATING:
<br>
$result = simplexml_load_string($response);
ERROR:
Warning (2): simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found [APP/Controller/EcommerceController.php, line 832]<br>
Warning (2): simplexml_load_string() [function.simplexml-load-string]: <?xml version='1.0' encoding='UTF-8'?><S:Envelope [APP/Controller/EcommerceController.php, line 832]<br>
Warning (2): simplexml_load_string() [function.simplexml-load-string]: ^ [APP/Controller/EcommerceController.php, line 832]
I tested your XML here and it worked ok. Some configuration in your php is removing the tag
<? ?>
XML. .– Albo Vieira
Maycon test the two examples separately please: http://answall.com/a/139663/3635 and tell me if both worked, otherwise tell me which one failed.
– Guilherme Nascimento