/**
  * Gets a xml based data and returns a new unit test data object with those values
  * @param SimpleXMLElement $xml
  * @return KalturaTestDataObject the new unit test data object with the given data
  */
 public function fromXml($xml)
 {
     $this->type = (string) $xml['type'];
     $this->dataObject = KalturaTestDataObject::getObjectInstance($this->type);
     $this->additionalData = kXml::getAttributesAsArray($xml);
     if (class_exists($this->type)) {
         foreach ($xml->children() as $child) {
             $childKey = $child->getName();
             //if dbValue exists
             if (isset($child["dbValue"])) {
                 $commentValue = $child['dbValue'];
                 $this->comments[$childKey] = "{$commentValue}";
             }
             if (strlen($child) != 0) {
                 $childValue = (string) $child;
             } else {
                 $childValue = null;
             }
             $childValueType = (string) $child["type"];
             try {
                 //TODO: Handle fields which are arrays (currently handled hard coded)
                 if ($childKey == "array" || $childKey == "Array") {
                     $arrayValue = array();
                     $arrayKey = $childValue;
                     foreach ($child->children() as $singleElementKey => $singleElementValue) {
                         if (isset($singleElementValue["key"])) {
                             $key = (string) $singleElementValue["key"];
                             $arrayValue[$key] = (string) $singleElementValue;
                         }
                         $arrayKey = $singleElementKey;
                         //if dbValue exists
                         if (isset($singleElementValue["dbValue"])) {
                             $singleElementComment = $singleElementValue["dbValue"];
                             $this->comments[$singleElementKey][$key] = "{$singleElementComment}";
                         }
                     }
                     if (count($arrayValue) > 0) {
                         KalturaTestDataObject::setPropertyValue($this->dataObject, $arrayKey, $arrayValue, $childValueType);
                     } else {
                         KalturaTestDataObject::setPropertyValue($this->dataObject, $arrayKey, $arrayValue, 'Array');
                     }
                 } else {
                     KalturaTestDataObject::setPropertyValue($this->dataObject, $childKey, $childValue, $childValueType);
                 }
             } catch (Exception $e) {
                 throw new Exception("Error can't set by name: " . $childValue . $e, $e->getCode());
             }
         }
     } else {
         //Handle no classes objects like string and int
         $child = $xml->children();
         if ($this->type == 'fileHandler') {
             KalturaTestDataObject::setPropertyValue($this->value, "value", file_get_contents(getcwd() . (string) $xml['key']), null);
         } else {
             if (count($child) == 0) {
                 KalturaTestDataObject::setPropertyValue($this->value, "value", trim($xml), null);
             } else {
                 KalturaTestDataObject::setPropertyValue($this->value, "value", $child->saveXML(), null);
             }
         }
     }
 }