Ejemplo n.º 1
0
 /**
  * Callback for XML parser
  *
  * @param   resource parser
  * @param   string name
  * @see     xp://xml.parser.XMLParser
  */
 public function onEndElement($parser, $name)
 {
     static $trans;
     $path = $this->_pathname();
     parent::onEndElement($parser, $name);
     if ($this->_cnt <= 0) {
         return;
     }
     // Replace &lt; &amp;, &#XX; etc.
     if (!isset($trans)) {
         $trans = array_flip(get_html_translation_table(HTML_SPECIALCHARS));
     }
     $cdata = trim($this->_objs[$this->_cnt + 1]->content);
     $name = strtr(substr($path, 0, -1), ['/rdf:rdf/' => '', '/rss/' => '']);
     switch ($name) {
         case 'channel/title':
             $this->channel->title = $cdata;
             break;
         case 'channel/link':
             $this->channel->link = $cdata;
             break;
         case 'channel/description':
             $this->channel->description = $cdata;
             break;
         case 'channel/language':
         case 'channel/dc:language':
             $this->channel->language = $cdata;
             break;
         case 'channel/copyright':
         case 'channel/dc:rights':
             $this->channel->copyright = $cdata;
             break;
         case 'channel/pubdate':
             // 14 May 2002
             $this->channel->date = new Date($cdata);
             break;
         case 'channel/dc:date':
             // 2002-07-12T15:59 or 2003-12-19T12:26:00+01:00
             $this->channel->date = new Date($cdata);
             break;
         case 'channel/dc:publisher':
             $this->channel->publisher = $cdata;
             break;
         case 'channel/dc:creator':
             $this->channel->creator = $cdata;
             break;
         case 'channel/image/url':
         case 'image/url':
             $this->image->url = $cdata;
             break;
         case 'channel/image/title':
         case 'image/title':
             $this->image->title = $cdata;
             break;
         case 'channel/image/link':
         case 'image/link':
             $this->image->link = $cdata;
             break;
         case 'channel/item/title':
         case 'item/title':
             $this->items[sizeof($this->items) - 1]->title = $cdata;
             break;
         case 'channel/item/description':
         case 'item/description':
             $this->items[sizeof($this->items) - 1]->description = $cdata;
             break;
         case 'channel/item/link':
         case 'item/link':
             $this->items[sizeof($this->items) - 1]->link = $cdata;
             break;
         case 'channel/item/date':
             // 14 May 2002
         // 14 May 2002
         case 'channel/item/pubdate':
             $this->items[sizeof($this->items) - 1]->date = new Date($cdata);
             break;
         case 'channel/item/dc:date':
             $this->items[sizeof($this->items) - 1]->date = new Date($cdata);
             break;
         case 'channel/item/category':
             $this->items[sizeof($this->items) - 1]->category = $cdata;
             break;
         case 'channel/item/author':
             $this->items[sizeof($this->items) - 1]->author = $cdata;
             break;
         case 'channel/item/content:encoded':
             $this->items[sizeof($this->items) - 1]->content = $cdata;
             break;
         case 'channel/item/guid':
             $this->items[sizeof($this->items) - 1]->guid = $cdata;
             break;
         case 'item/dc:date':
             // 2002-07-12T15:59 or 2003-12-19T12:26:00+01:00
             $this->items[sizeof($this->items) - 1]->date = new Date($cdata);
             break;
         default:
             // Ignore
     }
 }