Reputation: 7
I am using one payment gateway that return response as xml
and I am trying to convert to json
buy its not converting. I have tried that simplexamlloadfile
, simplexmlsting
function and etc.
But its not working.
Code :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header />
<SOAP-ENV:Body>
<ns2:SingleVaultResponse xmlns:ns2="http://www.paygate.co.za/PayHOST">
<ns2:LookUpVaultResponse>
<ns2:Status>
<ns2:StatusName>Completed</ns2:StatusName>
<ns2:PayVaultData>
<ns2:name>cardNumber</ns2:name>
<ns2:value>411111xxxxx1111</ns2:value>
</ns2:PayVaultData>
<ns2:PayVaultData>
<ns2:name>expDate</ns2:name>
<ns2:value>012025</ns2:value>
</ns2:PayVaultData>
<ns2:PaymentType>
<ns2:Method>CC</ns2:Method>
<ns2:Detail>Visa</ns2:Detail>
</ns2:PaymentType>
</ns2:Status>
</ns2:LookUpVaultResponse>
</ns2:SingleVaultResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Upvotes: 0
Views: 228
Reputation: 46
Try this:
$string2 = 'your xml sting';
$doc = new DOMDocument;
$doc->loadXML($string2);
echo "status => ".$doc->getElementsByTagName('Status')->item(0)->nodeValue;
Upvotes: 1