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


PHP DOMElement::setAttributeNode方法代碼示例

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


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

示例1: appendSceneComponents

 /**
  * Add scene components
  * 
  * @param array $components
  * @return void
  */
 public function appendSceneComponents(array $components)
 {
     foreach ($components as $component) {
         /*
          * Check does component has any attributes to add to scene DOM element.
          * default attributes most of cases are ommited so we might not have any attributes to add
          */
         if ($component->hasDOMAttributes()) {
             $this->scene->setAttributeNode($component->getDOMAttr());
         }
     }
 }
開發者ID:mkungla,項目名稱:aframe-php,代碼行數:18,代碼來源:AframeDOMDocument.php

示例2: importAttribute

 /**
  * @param \DOMElement $parent
  * @param \DOMAttr $source
  */
 private function importAttribute(\DOMElement $parent, \DOMAttr $source)
 {
     $document = $parent instanceof \DOMDocument ? $parent : $parent->ownerDocument;
     $namespaceUri = $this->getMappedNamespace($source->namespaceURI);
     if (empty($namespaceUri) || empty($source->prefix)) {
         $attribute = $document->createAttribute($source->localName);
     } else {
         $attribute = $document->createAttributeNS($namespaceUri, $source->nodeName);
     }
     $attribute->value = $source->value;
     $parent->setAttributeNode($attribute);
 }
開發者ID:fluentdom,項目名稱:fluentdom,代碼行數:16,代碼來源:Replace.php

示例3: initializeNode

 /**
  * Initialize a node with the readability object. Also checks the
  * className/id for special names to add to its score.
  *
  * @param \DOMElement $node
  */
 protected function initializeNode($node)
 {
     if (!isset($node->tagName)) {
         return;
     }
     $readability = $this->dom->createAttribute('readability');
     // this is our contentScore
     $readability->value = 0;
     $node->setAttributeNode($readability);
     // using strtoupper just in case
     switch (strtoupper($node->tagName)) {
         case 'ARTICLE':
             $readability->value += 15;
         case 'DIV':
             $readability->value += 5;
             break;
         case 'PRE':
         case 'CODE':
         case 'TD':
         case 'BLOCKQUOTE':
         case 'FIGURE':
             $readability->value += 3;
             break;
         case 'SECTION':
             // often misused
             // $readability->value += 2;
             break;
         case 'OL':
         case 'UL':
         case 'DL':
         case 'DD':
         case 'DT':
         case 'LI':
             $readability->value -= 2 * round($this->getLinkDensity($node), 0, PHP_ROUND_HALF_UP);
             break;
         case 'ASIDE':
         case 'FOOTER':
         case 'HEADER':
         case 'ADDRESS':
         case 'FORM':
         case 'BUTTON':
         case 'TEXTAREA':
         case 'INPUT':
         case 'NAV':
             $readability->value -= 3;
             break;
         case 'H1':
         case 'H2':
         case 'H3':
         case 'H4':
         case 'H5':
         case 'H6':
         case 'TH':
         case 'HGROUP':
             $readability->value -= 5;
             break;
     }
     $readability->value += $this->getWeight($node);
 }
開發者ID:j0k3r,項目名稱:php-readability,代碼行數:65,代碼來源:Readability.php

示例4: _addAttr

 /**
  * Helper to add a attribute
  *
  * @param  DOMElement $parent
  * @param  string $name
  * @param  mixed $value
  *
  * @return void
  */
 protected function _addAttr($parent, $name, $value)
 {
     $parent->setAttributeNode(new DOMAttr($name, $value));
 }
開發者ID:hpbuniat,項目名稱:SiteQ,代碼行數:13,代碼來源:Xml.php

示例5: _setStyleAttributeValue

 /**
  * Style attribute gets it's own setter as it's more complex than typical
  *
  * @param bool $returnAttr
  * @return DOMElementPlus|\DOMAttr
  */
 protected function _setStyleAttributeValue($returnAttr = false)
 {
     if ($this->hasAttribute('style')) {
         $attr = $this->getAttributeNode('style');
         $attr->value = $this->_getStyleAttributeString();
     } else {
         $attr = new \DOMAttr('style', $this->_getStyleAttributeString());
         parent::setAttributeNode($attr);
     }
     return $returnAttr ? $attr : $this;
 }
開發者ID:dcarbone,項目名稱:dom-plus,代碼行數:17,代碼來源:DOMElementPlus.php


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