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


PHP XMLElement::getAttrib方法代碼示例

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


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

示例1: addElement

 public function addElement(XMLElement $element)
 {
     $name = $element->name();
     $value = $element->value();
     switch ($name) {
         case 'LINK':
             if (!$value) {
                 if ($link = $element->getAttrib('HREF')) {
                     $element->shouldStripTags(true);
                     $element->setValue($link);
                 }
             }
             parent::addElement($element);
             break;
         case 'enclosure':
             $this->enclosure = $element;
             $this->enclosures[] = $element;
             break;
         case 'image':
             $this->images[] = $element;
             break;
         case 'CATEGORY':
             $name = strtolower($name);
             array_push($this->{$name}, $value);
             break;
         case 'PUBDATE':
         case 'DC:DATE':
         case 'PUBLISHED':
         case 'UPDATED':
             if ($value = $element->value()) {
                 try {
                     if ($date = new DateTime($value)) {
                         $this->pubDate = $date;
                     }
                 } catch (Exception $e) {
                 }
             }
             break;
         case 'AUTHOR':
             if ($name = $element->getProperty('name')) {
                 $this->author = $name;
             } else {
                 parent::addElement($element);
             }
             break;
         default:
             parent::addElement($element);
             break;
     }
 }
開發者ID:sponto,項目名稱:Kurogo-Mobile-Web,代碼行數:50,代碼來源:RSSItem.php

示例2: addElement

    public function addElement(XMLElement $element)
    {
        $name = $element->name();
        $value = $element->value();

        switch ($name)
        {
            case 'NAME':
                $this->layerName = $value;
                break;
            case 'TITLE':
                $this->title = $value;
                break;
            case 'ABSTRACT':
                $this->abstract = $value;
                break;
            case 'MAXSCALEDENOMINATOR':
                $this->maxScaleDenom = $value;
                break;
            case 'MINSCALEDENOMINATOR':
                $this->minScaleDenom = $value;
                break;
            case 'CRS':
                $projNumber = end(explode(':', $value));
                $this->projections[$projNumber] = $value;
                break;
            case 'EX_GEOGRAPHICBOUNDINGBOX':
                $this->bboxes[self::GEOGRAPHIC_PROJECTION] = array(
                    'xmin' => $element->getProperty('WESTBOUNDLONGITUDE'),
                    'xmax' => $element->getProperty('EASTBOUNDLONGITUDE'),
                    'ymin' => $element->getProperty('SOUTHBOUNDLATITUDE'),
                    'ymax' => $element->getProperty('NORTHBOUNDLATITUDE'),
                    );
                break;
            case 'BOUNDINGBOX':
                $this->bboxes[$element->getAttrib('CRS')] = array(
                    'xmin' => $element->getAttrib('MINX'),
                    'xmax' => $element->getAttrib('MAXX'),
                    'ymin' => $element->getAttrib('MINY'),
                    'ymax' => $element->getAttrib('MAXY'),
                    );
                break;
            case 'STYLE':
                $this->styles[] = $element;
                break;
            default:
                parent::addElement($element);
                break;
        }
    }
開發者ID:nicosiseng,項目名稱:Kurogo-Mobile-Web,代碼行數:50,代碼來源:WMSDataParser.php

示例3: addElement

 public function addElement(XMLElement $element)
 {
     $name = $element->name();
     $value = $element->value();
     switch ($name) {
         case 'LINK':
             if (!$value) {
                 if ($link = $element->getAttrib('HREF')) {
                     $element->setValue($link, true);
                 }
             }
             parent::addElement($element);
             break;
         case 'enclosure':
             $this->enclosure = $element;
             break;
         case 'image':
             $this->images[] = $element;
             break;
         case 'CATEGORY':
             $name = strtolower($name);
             array_push($this->{$name}, $value);
             break;
         default:
             parent::addElement($element);
             break;
     }
 }
開發者ID:hxfnd,項目名稱:Kurogo-Mobile-Web,代碼行數:28,代碼來源:RSS.php

示例4: addElement

 public function addElement(XMLElement $element)
 {
     $name = $element->name();
     $value = $element->value();
     switch ($name) {
         case 'NAME':
             $this->layerName = $value;
             break;
         case 'TITLE':
             $this->title = $value;
             break;
         case 'ABSTRACT':
             $this->abstract = $value;
             break;
         case 'MAXSCALEDENOMINATOR':
             $this->maxScaleDenom = $value;
             break;
         case 'MINSCALEDENOMINATOR':
             $this->minScaleDenom = $value;
             break;
         case 'CRS':
             $projNumber = end(explode(':', $value));
             if ($projNumber == '4326') {
                 // 4326 flips x and y cooordinates (x = lat, y = lon)
                 // TODO we need a better way to deal with this special case
                 $this->projections[$projNumber] = self::GEOGRAPHIC_PROJECTION;
             } else {
                 $this->projections[$projNumber] = $value;
             }
             break;
         case 'EX_GEOGRAPHICBOUNDINGBOX':
             $this->bboxes[self::GEOGRAPHIC_PROJECTION] = array('xmin' => floatval($element->getProperty('WESTBOUNDLONGITUDE')), 'xmax' => floatval($element->getProperty('EASTBOUNDLONGITUDE')), 'ymin' => floatval($element->getProperty('SOUTHBOUNDLATITUDE')), 'ymax' => floatval($element->getProperty('NORTHBOUNDLATITUDE')));
             break;
         case 'BOUNDINGBOX':
             $this->bboxes[$element->getAttrib('CRS')] = array('xmin' => floatval($element->getAttrib('MINX')), 'xmax' => floatval($element->getAttrib('MAXX')), 'ymin' => floatval($element->getAttrib('MINY')), 'ymax' => floatval($element->getAttrib('MAXY')));
             break;
         case 'STYLE':
             $this->styles[] = $element;
             break;
         default:
             parent::addElement($element);
             break;
     }
 }
開發者ID:nncsang,項目名稱:Kurogo,代碼行數:44,代碼來源:WMSDataParser.php


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