<?php
$soapUrl = "http://10.65.28.221/Magic94Scripts/mgrqispi94.dll";
$xml_post_string = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:car="CarproPriceEstimation">
<soapenv:Header/>
<soapenv:Body>
<car:EstimationDetails UserId="TEST" UserPassword="TEST">
<!--1 or more repetitions:-->
<car:Price>
<car:CDP></car:CDP>
<car:OutBranch>'.$_SESSION["pickup-location"].'</car:OutBranch>
<car:InBranch>'.$_SESSION["dropLocation"].'</car:InBranch>
<car:OutDate>'.$_SESSION["pickupDate"].'</car:OutDate>
<car:OutTime>'.$_SESSION["pickupTime"].'</car:OutTime>
<car:InDate>'.$_SESSION["dropDate"].'</car:InDate>
<car:InTime>'.$_SESSION["dropTime"].'</car:InTime>
<car:CarGroup>'.$_SESSION["car-type"].'</car:CarGroup>
</car:Price>
</car:EstimationDetails>
</soapenv:Body>
</soapenv:Envelope>';
$headers = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPAction: 3575E6F6964716D6964737545636962705F237375636F62705024727F607D694A336F646",
"Content-length: ".strlen($xml_post_string),
);
$url = $soapUrl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string );
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result=curl_exec($ch);
curl_close($ch);
// $xml= (array) simplexml_load_string($result);
// var_dump($xml);
$xml = simplexml_load_string($result, "SimpleXMLElement", LIBXML_NOCDATA);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
var_dump($array);
//
// $xml = simplexml_load_string($result);
// print_r($xml);
// // $json = json_encode($xml);
// // $ctarray = json_decode($json,TRUE);
// echo $ctarray;
?>
I am trying to get xml return data in my html by converting into array or anyway i have html on same page want to get some values from xml at different places of HTML. I have expected date of some car prices from API which i will show on the same page, i am not using ajax simply redirecting to page where curl will run and will display data on bottom of html page.
I am getting this XML on return when i echo result.
<soap-env:envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"><soap-env:body><estimationdetails>
<price>
<debitorcode></debitorcode>
<cdp></cdp>
<vouchertype></vouchertype>
<vouchercode></vouchercode>
<cargroup>A</cargroup>
<currency></currency>
<outbranch>66</outbranch>
<inbranch>66</inbranch>
<outdate>01/03/2020</outdate>
<outtime>06:30</outtime>
<indate>01/04/2020</indate>
<intime>02:30</intime>
<status>Status : Confirmed</status>
<cargroupprice cargroup="A">
<rateno>0</rateno>
<ratename></ratename>
<solddays>31.00</solddays>
<rentalsum>0.0000</rentalsum>
<insurancesum>0.0000</insurancesum>
<extrassum>0.0000</extrassum>
<dropoffsum>0.0000</dropoffsum>
<airportfee>0.0000</airportfee>
<vatperc>5.00</vatperc>
<vatamount>0.0000</vatamount>
<totalamount>0.0000</totalamount>
<alert></alert>
<caravailable>Available</caravailable>
<tariffcode>DEFAULT</tariffcode>
</cargroupprice>
</price>
<success>Y</success>
</estimationdetails></soap-env:body></soap-env:envelope>