/**
  * 
  * Returns a DomDocument containing the test case failure
  * @param KalturaTestCaseInstanceFailure $failure
  * @param string $rootNodeName - default to 'data'
  * @return DOMDocument - the xml for the given error
  */
 public static function toXml(KalturaTestCaseInstanceFailure $testCaseInstanceFailure, $rootNodeName = 'data')
 {
     if (count($testCaseInstanceFailure->getFailures()) == 0) {
         return new DOMDocument("1.0");
     }
     $dom = new DOMDocument(1.0);
     $rootNode = $dom->createElement($rootNodeName);
     $dom->appendChild($rootNode);
     $rootNode->setAttribute("testCaseInstanceName", $testCaseInstanceFailure->getTestCaseInstanceName());
     $inputsNode = $dom->createElement("Inputs");
     foreach ($testCaseInstanceFailure->getTestCaseInput() as $inputKey => $inputValue) {
         $node = $dom->createElement("Input");
         if ($inputValue != null) {
             $type = gettype($inputValue);
             if (is_object($inputValue)) {
                 $class = get_class($inputValue);
                 KalturaLog::debug("class [" . $class . "]\n");
                 if (class_exists($class)) {
                     $type = get_class($inputValue);
                 }
             }
             $node->setAttribute("type", $type);
             $id = $inputValue;
             if ($inputValue instanceof BaseObject) {
                 $id = $inputValue->getId();
             } elseif ($inputValue instanceof KalturaObjectBase || $inputValue instanceof KalturaObject) {
                 if (property_exists($inputValue, 'id')) {
                     $id = $inputValue->id;
                 }
             }
             //Fixes problem where id was object
             if (is_object($id)) {
                 $idType = get_class($id);
                 $id = "not a string but {$idType}";
             }
             $node->setAttribute($type . "Id", $id);
         }
         $inputsNode->appendChild($node);
     }
     $failuresNode = $dom->createElement("Failures");
     foreach ($testCaseInstanceFailure->getFailures() as $kalturaFailure) {
         $objectAsDOM = KalturaFailure::toXml($kalturaFailure, "Failure");
         kXml::appendDomToElement($objectAsDOM, $failuresNode, $dom);
     }
     $rootNode->appendChild($inputsNode);
     $rootNode->appendChild($failuresNode);
     //pass back DomElement object
     return $dom;
 }