Reputation: 31
I am getting Sabre SOAP API response something like :
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
<soap-env:header></soap-env:header>
<soap-env:body>
<ota_airlowfaresearchrs xmlns="http://www.opentravel.org/OTA/2003/05" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.1.0" priceditincount="50" brandedonewayitincount="0" simpleonewayitincount="0" departeditincount="0" soldoutitincount="0" availableitincount="0">
<success>
<priceditineraries><priceditinerary sequencenumber="1"></priceditinerary>
<priceditinerary sequencenumber="2"></priceditinerary></priceditineraries>
</success>
</ota_airlowfaresearchrs>
</soap-env:body>
</soap-env:envelope>
But when I tried with simplexml_load_string I am getting a problem to convert it to PHP array. what I tried is :
$parser = simplexml_load_string($res);
$parserEnv = $parser->children('soap-env', true);
$response = $parserEnv->body->ota_airlowfaresearchrs;
its return emptry array like : SimpleXMLElement Object ( )
Upvotes: 1
Views: 543
Reputation: 31
As ref to : converting SOAP XML response to a PHP object or array
I got the answer by doing the following way:
$soap = simplexml_load_string($res);
$response = $soap->children('http://schemas.xmlsoap.org/soap/envelope/')
->body->children()
->ota_airlowfaresearchrs
->success
->priceditineraries
thanks @lalithkumar any way
Upvotes: 1
Reputation: 3540
From
$parser = simplexml_load_string($res);
you have to change like below:
$parser = simplexml_load_string($res, "SimpleXMLElement", LIBXML_NOCDATA);
LIBXML_NOCDATA : You can use this function call to have simplexml convert CDATA into plain text.
Upvotes: 0