当前位置: 首页>>代码示例>>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;未经允许,请勿转载。