public static function fromXML($type, $xml) { $obj = new self($type); foreach ($xml->attributes() as $k => $v) { $obj->addAttr($k, $v); } foreach ($xml as $k => $v) { $obj->addChild($k, ResponseObj::fromXML($k, $v)); } return $obj; }