/**
  * returns the Object as associated array
  * @return array
  */
 public function toArray()
 {
     if ($this->_element instanceof PhealArrayInterface) {
         return array('currentTime' => $this->request_time, 'cachedUntil' => $this->cached_until, 'result' => $this->_element->toArray());
     } else {
         return array();
     }
 }
 /**
  * initialize the rowset
  * @param SimpleXMLElement $xml
  * @optional String $name
  * @optional String $rowname
  */
 public function __construct($xml, $name = null, $rowname = 'row')
 {
     $this->_name = (string) ($name !== null) ? $name : $xml->attributes()->name;
     foreach ($xml->{$rowname} as $rowxml) {
         $row = array();
         foreach ($rowxml->attributes() as $attkey => $attval) {
             $row[$attkey] = (string) $attval;
         }
         foreach ($rowxml->children() as $child) {
             $element = PhealElement::parse_element($child);
             $row[(string) $element->_name] = $element;
         }
         $rowObject = new PhealRowSetRow($row);
         $rowObject->setStringValue((string) $rowxml);
         $this->append($rowObject);
     }
 }
 /**
  * parse SimpleXMLElement
  * @param SimpleXMLElement $element
  * @return mixed
  */
 public static function parse_element($element)
 {
     if ($element->getName() == "rowset") {
         $re = new PhealRowSet($element);
     } elseif ($element->getName() == "result" && $element->member) {
         $container = new PhealContainer();
         $container->add_element('members', new PhealRowSet($element, 'members', 'member'));
         $re = new PhealElement('result', $container);
     } else {
         $key = $element->getName();
         $echilds = $element->children();
         if (count($echilds) > 0) {
             $container = new PhealContainer();
             foreach ($echilds as $celement) {
                 $cel = PhealElement::parse_element($celement);
                 if (count($celement->attributes()) > 0) {
                     $container->add_element($cel->_name, $cel);
                 } else {
                     $container->add_element($cel->_name, $cel->_value);
                 }
             }
             $value = $container;
         } else {
             $value = (string) $element;
         }
         $re = new PhealElement($key, $value);
         if (count($element->attributes()) > 0) {
             foreach ($element->attributes() as $attelem) {
                 $re->add_attrib($attelem->getName(), (string) $attelem);
             }
         }
     }
     return $re;
 }