當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SimpleXmlElement::getNamespaces方法代碼示例

本文整理匯總了PHP中SimpleXmlElement::getNamespaces方法的典型用法代碼示例。如果您正苦於以下問題:PHP SimpleXmlElement::getNamespaces方法的具體用法?PHP SimpleXmlElement::getNamespaces怎麽用?PHP SimpleXmlElement::getNamespaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SimpleXmlElement的用法示例。


在下文中一共展示了SimpleXmlElement::getNamespaces方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse

 public function parse()
 {
     $sXML = new \SimpleXmlElement($this->xml);
     $ns = $sXML->getNamespaces(true);
     foreach ((array) $sXML->channel as $k => $v) {
         if ($k == 'item') {
             continue;
         }
         if (!is_string($v) && !is_array($v)) {
             $v = (array) $v;
         }
         $this->meta[$k] = $v;
     }
     foreach ($sXML->channel->item as $item) {
         $i = (array) $item;
         foreach ($ns as $space => $val) {
             $children = $item->children($val);
             if ($children) {
                 foreach ($children as $c => $a) {
                     $i[$c] = (string) $a;
                 }
             }
         }
         $this->items[] = $i;
     }
 }
開發者ID:sketchmedia,項目名稱:sketchguild,代碼行數:26,代碼來源:Rss.php

示例2: get

 public function get($count = -1, $rating = null, $filter = null)
 {
     if ($count == 0 || !is_numeric($count)) {
         $count = -1;
     }
     $url = sprintf(self::BACKEND_URL, $this->username) . ($filter == -1 ? '+in%3Ascraps' : '') . ($filter > 0 ? '%2F' . $filter : '');
     $this->data = $this->request($url);
     $xml = new SimpleXmlElement($this->data);
     $ns = $xml->getNamespaces(true);
     $items = null;
     foreach ($xml->channel->item as $item) {
         $media = $item->children($ns['media']);
         if (!(empty($this->rating) || $this->rating == 'all') && $media->rating != $this->rating) {
             continue;
         }
         if ($media->text) {
             continue;
         }
         if ($media->text) {
             continue;
         }
         if ($media->text) {
             continue;
         }
         $items .= sprintf('<li><a href="%1$s" title="%2$s - %3$s"><img src="%4$s" alt="%2$s - %3$s"/></a></li>', $item->link, $media->title, $media->copyright, $media->content->attributes()->url);
         --$count;
         if ($count > -1 && $count == 0) {
             break;
         }
     }
     return sprintf('<ul class="da-widgets gallery">%s</ul>', $items);
 }
開發者ID:aegypius,項目名稱:wp-da-widgets,代碼行數:32,代碼來源:Gallery.php

示例3: get

 public function get($count = -1)
 {
     $xml = new SimpleXmlElement($this->data);
     $ns = $xml->getNamespaces(true);
     $items = null;
     foreach ($xml->channel->item as $item) {
         $items .= sprintf('<dt><a href="%2$s">%1$s</a></dt>' . '<dd>' . '<p>%3$s</p>' . '</dd>', $item->title, $item->link, $item->description);
         --$count;
         if ($count > -1 && $count == 0) {
             break;
         }
     }
     return sprintf('<dl>%s</dl>', $items);
 }
開發者ID:Honigkuchenwolf,項目名稱:wp-da-widgets,代碼行數:14,代碼來源:Log.php

示例4: get

 public function get($count = -1)
 {
     $xml = new SimpleXmlElement($this->data);
     $ns = $xml->getNamespaces(true);
     $items = null;
     foreach ($xml->channel->item as $item) {
         $media = $item->children($ns['media']);
         if (!(is_null($this->rating) || $this->rating == 'all') && $media->rating != $this->rating) {
             continue;
         }
         $items .= sprintf('<li><a href="%1$s" title="%2$s - %3$s"><img src="%4$s" alt="%2$s - %3$s"/></a></li>', $item->link, $media->title, $media->copyright, $media->content->attributes()->url);
         --$count;
         if ($count > -1 && $count == 0) {
             break;
         }
     }
     return sprintf('<ul class="da-widgets favourite">%s</ul>', $items);
 }
開發者ID:Honigkuchenwolf,項目名稱:wp-da-widgets,代碼行數:18,代碼來源:Favourite.php

示例5: get

 public function get($count = -1, $format = 1)
 {
     if ($count == 0 || !is_numeric($count)) {
         $count = -1;
     }
     $url = sprintf(self::BACKEND_URL, $this->username, $format);
     $this->data = $this->request($url);
     $xml = new SimpleXmlElement($this->data);
     $ns = $xml->getNamespaces(true);
     $items = null;
     foreach ($xml->channel->item as $item) {
         $items .= sprintf('<dt><a href="%2$s">%1$s</a></dt>' . '<dd>' . '<p>%3$s</p>' . '</dd>', $item->title, $item->link, $item->description);
         --$count;
         if ($count > -1 && $count == 0) {
             break;
         }
     }
     return sprintf('<dl class="da-widgets log">%s</dl>', $items);
 }
開發者ID:aegypius,項目名稱:wp-da-widgets,代碼行數:19,代碼來源:Log.php


注:本文中的SimpleXmlElement::getNamespaces方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。