I've fired a curl request. My code is
$URL = "http://demo.com";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_MUTE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xmlLeadCloud");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
Below I am getting the XML in $output variable.
<?xml version="1.0" encoding="utf-16"?>
<LeadCloud>
<InsuranceSvcRs>
<PersHealthPolicyQuoteInqRs>
<MsgStatus>
<MsgStatusCd>Success</MsgStatusCd>
<Payout>17.40</Payout>
<BuyerLeadId>4ded4da790c6fasasasas322</BuyerLeadId>
<BuyerId>34</BuyerId>
</MsgStatus>
</PersHealthPolicyQuoteInqRs>
</InsuranceSvcRs>
</LeadCloud>
How could I get MsgStatusCd element's value from it. So far I've tried.
$s = new SimpleXMLElement($output);
echo $s->InsuranceSvcRs->PersHealthPolicyQuoteInqRs->MsgStatus->MsgStatusCd; die; //not working
$s->InsuranceSvcRs->PersHealthPolicyQuoteInqRs->MsgStatus->MsgStatusCd;In my case it should showSuccessSimpleXMLElement::__construct(): Entity: line 1: parser error : Document labelled UTF-16 but has UTF-8 content in..utf-8, and use this for changing.