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


PHP DOMNode::isSameNode方法代碼示例

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


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

示例1: switch

 public function &appendNode(DOMNode &$a_tag)
 {
     switch ($this->m_node->nodeType) {
         case XML_DOCUMENT_NODE:
             $node = $this->m_node->isSameNode($a_tag->ownerDocument) ? $a_tag : $this->m_node->importNode($a_tag, true);
             $this->m_node->appendChild($a_tag);
             return $this;
         case XML_ELEMENT_NODE:
             $node = $this->m_node->ownerDocument->isSameNode($a_tag->ownerDocument) ? $a_tag : $this->m_node->ownerDocument->importNode($a_tag, true);
             $this->m_node->appendChild($node);
             return $this;
     }
     return $this;
 }
開發者ID:BGCX261,項目名稱:zoombi-svn-to-git,代碼行數:14,代碼來源:xmltag.php

示例2: insertNode

 protected function insertNode(DOMNode $tmp, DOMNode $node, $mode)
 {
     if ($mode === 'before' || $mode === 'after') {
         if ($node instanceof DOMText || $node instanceof DOMElement || $node instanceof DOMDocumentFragment) {
             if ($tmp->isSameNode($tmp->ownerDocument->documentElement)) {
                 throw new BadMethodCallException('Cannot insert a ' . get_class($node) . ' node outside of the root node');
             }
         }
         if ($mode === 'before') {
             return $tmp->parentNode->insertBefore($node, $tmp);
         }
         if ($tmp->nextSibling) {
             return $tmp->parentNode->insertBefore($node, $tmp->nextSibling);
         }
         return $tmp->parentNode->appendChild($node);
     }
     return $tmp->appendChild($node);
 }
開發者ID:ketwaroo,項目名稱:simple-dom,代碼行數:18,代碼來源:SimpleDOM.php

示例3: createXPath

 /**
  * Create XPath
  *
  * @param \DOMNode $node
  * @return string
  */
 protected function createXPath(\DOMNode $node)
 {
     $parentXPath = '';
     $currentXPath = $node->getNodePath();
     if ($node->parentNode !== null && !$node->isSameNode($node->parentNode)) {
         $parentXPath = $this->createXPath($node->parentNode);
         $pathParts = explode('/', $currentXPath);
         $currentXPath = '/' . end($pathParts);
     }
     $attributesXPath = '';
     if ($node->hasAttributes()) {
         $attributes = [];
         foreach ($node->attributes as $name => $attribute) {
             if ($this->isIdAttribute($name)) {
                 $attributes[] = sprintf('@%s="%s"', $name, $attribute->value);
                 break;
             }
         }
         if (!empty($attributes)) {
             if (substr($currentXPath, -1) === ']') {
                 $currentXPath = substr($currentXPath, 0, strrpos($currentXPath, '['));
             }
             $attributesXPath = '[' . implode(' and ', $attributes) . ']';
         }
     }
     return '/' . trim($parentXPath . $currentXPath . $attributesXPath, '/');
 }
開發者ID:vrann,項目名稱:magento2-from-vendor,代碼行數:33,代碼來源:DomMerger.php

示例4: drawThumbnailZone

 /**
  * Draw a final layout zone on its thumbnail.
  *
  * @access private
  *
  * @param ressource $thumbnail  The thumbnail ressource
  * @param DOMNode   $node       The current node zone
  * @param array     $clip       The clip rect to draw
  * @param int       $background The background color
  * @param int       $gridcolumn The number of columns in the grid
  * @param boolean   $lastChild  True if the current node is the last child of its parent node
  *
  * @return int The new X axis position;
  */
 private function drawThumbnailZone(&$thumbnail, $node, $clip, $background, $gridcolumn, $lastChild = false)
 {
     $x = $clip[0];
     $y = $clip[1];
     $width = $clip[2];
     $height = $clip[3];
     if (null !== ($spansize = preg_replace('/[^0-9]+/', '', $node->getAttribute('class')))) {
         $width = floor($width * $spansize / $gridcolumn);
     }
     if (false !== strpos($node->getAttribute('class'), 'Child')) {
         $height = floor($height / 2);
     }
     if (!$node->hasChildNodes()) {
         $this->drawRect($thumbnail, array($x, $y, $width, $height), $background, $width == $clip[2] || strpos($node->getAttribute('class'), 'hChild'), $lastChild);
         return $width + 2;
     }
     foreach ($node->childNodes as $child) {
         if (is_a($child, 'DOMText')) {
             continue;
         }
         if ('clear' == $child->getAttribute('class')) {
             $x = $clip[0];
             $y = $clip[1] + floor($height / 2) + 2;
             continue;
         }
         $x += $this->drawThumbnailZone($thumbnail, $child, array($x, $y, $clip[2], $height), $background, $gridcolumn, $node->isSameNode($node->parentNode->lastChild));
     }
     return $x + $width - 2;
 }
開發者ID:gobjila,項目名稱:BackBee,代碼行數:43,代碼來源:LayoutRepository.php

示例5: nodeIndex

 private function nodeIndex(DOMNode $n)
 {
     $cnt = 0;
     foreach ($n->parentNode->childNodes as $n2) {
         if ($n->isSameNode($n2)) {
             return $cnt;
         }
         $cnt++;
     }
     return false;
 }
開發者ID:samuelkato,項目名稱:DOMRange,代碼行數:11,代碼來源:DOMRange.php


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