mardi 5 mai 2015

retrieving values from XML

I am trying to convert this XML to array this is the response I am getting from API and I want to get the value of statuscode but I am unable to do it.

<?xml version='1.0' encoding='utf-8' standalone='no'?>
<REGISTRATIONRESPONSE>
<STATUSCODE>20</STATUSCODE>
<STATUS>1234</STATUS> 
</REGISTRATIONRESPONSE>

but when i am using the following code

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 6);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,'RequestData='.$post);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
$result = curl_exec($ch);
$resultres=xml2ary($result);
echo '<pre>';
print_r($resultres);

The output is

Array
 (
    [string] => Array
    (
            [_a] => Array
            (
                [xmlns] => http://tempuri.org/
            )
            [_v] => 201234
    )
)

How is the result changing? I have used one more technique also but with that also I am not getting the result that is required

Aucun commentaire:

Enregistrer un commentaire