I am writing a test script in php. I get back XML from the server in simplexml objects. Ive been parsing most fine, some using foreach loops and some directly from the elements. This one response just will not let me store the value to a PHP variable.
This is the specific response
<xml>
<status>1</status>
<count>1</count>
<device id="72220">
<udid>99000146864366</udid>
<devicename>Sprint Wwe</devicename>
<created>2014-07-01 13:22:27</created>
</device>
</xml>
Here is my parsing block
$cRes = $proxy->queryXML($section, 'retrieve', array("device_id" => "all"));
if($cRes->status == '1'){
$dvcID = $cRes->device[0]['id']->__toString();
$devicename = $cRes->device[0]->devicename->__toString();
if(empty($dvcID)) return $do;//
if(empty($devicename)) return $do2;//hacked break points
$res = array("deviceid" => $dvcID,
"devicename" => $devicename);
return $res;
}
The objective is to pull only id and devicename from the first device in an arbitrary amount of devices listed in the response. The php variables seem to not be empty as they dont return on my hacked break points(using notepad++). Ive tried casting them as (string) but they still show up with no data but do not fail the empty() test. Casting the id as an int turns it into a 0. What am I missing here?
The error response from the server is as follows
Last Query:Array
(
[device_id] =>
[devicename] =>
[return_type] => xml
[section] => devices
[action] => update
[api_key] => xxxxxxxxxxxxxxxxxx
)
Last Response<?xml version="1.0" encoding="utf-8"?>
<xml>
<status>0</status>
<error code="410">Required device POST variables not supplied</error>
</xml>