Pure XML in PHP

1

I am making a request to a web service (made in delphi), by PHP sending an XML and receiving a response.

What I want is to be able to show XML exactly as it is.

Code that I use: $getData is the request XML

$client = new SoapClient("http://192.168.1.164:8080/wsdl/IComanda");
$obj = $client->Requisicao($gtData);
$xml = simplexml_load_string($obj);
print_r ($xml);

Only what I get is similar to this (example taken from PHP):

SimpleXMLElement Object
(
  [title] => Forty What?
  [from] => Joe
  [to] => Jane
  [body] =>
)

How do I display the pure XML received from the web service?

    
asked by anonymous 27.05.2015 / 15:37

1 answer

3

Notice that by using simplexml_load_string() you are interpreting the response XML.

If you want pure XML just use the previous variable:

$client = new SoapClient("http://192.168.1.164:8080/wsdl/IComanda");
$obj = $client->Requisicao($gtData);

// Só para garantir que o código XML será exibido no navegador
header('Content-Type: application/xml; charset=utf-8');

echo $obj;
    
27.05.2015 / 15:45