Ejemplo n.º 1
0
 public function parse($content)
 {
     $xml = new KDOMDocument();
     try {
         $xml->loadXML(trim($content, " \r\n\t"));
     } catch (Exception $e) {
         KalturaLog::err($e->getMessage());
         return array();
     }
     // parse styles
     $xmlNS = $xml->lookupNamespaceURI('xml');
     $this->ttsNS = $xml->lookupNamespaceURI('tts');
     $elements = $xml->getElementsByTagName('style');
     $this->styles = array();
     foreach ($elements as $element) {
         if ($element->hasAttribute('id')) {
             $id = $element->getAttribute('id');
         } else {
             if ($element->hasAttributeNS($xmlNS, 'id')) {
                 $id = $element->getAttributeNS($xmlNS, 'id');
             } else {
                 continue;
             }
         }
         $style = $this->parseStyles($element);
         $this->styles[$id] = $style;
     }
     // parse content
     $itemsData = $this->parseBody($xml);
     if (!$itemsData) {
         KalturaLog::err("XML element <p> not found");
         return array();
     }
     return $itemsData;
 }