Esempio n. 1
0
 public function current()
 {
     if ($this->type == DOC_TYPE_ARRAY) {
         return CPS_Response::simpleXmlToArray(current($this->_data));
     } else {
         if ($this->type == DOC_TYPE_STDCLASS) {
             return CPS_Response::simpleXmlToStdClass(current($this->_data));
         } else {
             return current($this->_data);
         }
     }
 }
 /**
  * Converts SimpleXMLElement to stdClass
  */
 static function simpleXmlToStdClass(SimpleXMLElement &$source)
 {
     $res = new StdClass();
     $children = false;
     foreach ($source as $key => $value) {
         if (isset($res->{$key})) {
             if (!is_array($res->{$key})) {
                 $res->{$key} = array($res->{$key});
             }
             $ref =& $res->{$key};
             $ref[] = CPS_Response::simpleXmlToStdClass($value);
         } else {
             $res->{$key} = CPS_Response::simpleXmlToStdClass($value);
         }
         $children = true;
     }
     if (!$children) {
         return (string) $source;
     }
     return $res;
 }