View Full Version : PHP performing on XML response

11-22-2011, 08:36 AM
I send off this:

$data = "<egateway>
<eCardHoldersName>Joe Bloke</eCardHoldersName>
$ch = curl_init();
curl_setopt($ch, CURLOPT_POSTFIELDS, $edata);
curl_setopt($ch, CURLOPT_URL, "https://www.example.com/gateway_cvn/testpage.asp");

In return, I get the following XML:

<eTrxnError>00,Transaction Approved(Test CVN Gateway)</eTrxnError>

Is there a way to make it so this does not show, and instead I can make PHP do something like:

if (eTrxnStatus == True) {// do stuff};


11-22-2011, 11:53 AM
I'm using:

$response = simplexml_load_string(curl_exec($ch));
if ($response -> eTrxnStatus == 'True') {
echo "True 1111111111111.";

... but getting these errors:

PHP Warning:
simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found
simplexml_load_string(): 1
simplexml_load_string(): ^

PHP Notice: Trying to get property of non-object

The response code I am getting back in XML is:

<eResponse><eTrxnStatus>True</eTrxnStatus><eTrxnNumber>11673</eTrxnNumber><eTrxnReference/><eReturnAmount>100</eReturnAmount><eTrxnError>00,Transaction Approved(Test CVN Gateway)</eTrxnError></eResponse>

What could be causing this? I can't make any sense of it at all!

11-22-2011, 12:07 PM
I solved the problem with:

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);