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


PHP DOMNode::removeChild方法代碼示例

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


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

示例1:

 function remove_child(Frame $child, $update_node = true)
 {
     if ($child->_parent !== $this) {
         throw new DOMPDF_Exception("Child not found in this frame");
     }
     if ($update_node) {
         $this->_node->removeChild($child->_node);
     }
     if ($child === $this->_first_child) {
         $this->_first_child = $child->_next_sibling;
     }
     if ($child === $this->_last_child) {
         $this->_last_child = $child->_prev_sibling;
     }
     if ($child->_prev_sibling) {
         $child->_prev_sibling->_next_sibling = $child->_next_sibling;
     }
     if ($child->_next_sibling) {
         $child->_next_sibling->_prev_sibling = $child->_prev_sibling;
     }
     $child->_next_sibling = null;
     $child->_prev_sibling = null;
     $child->_parent = null;
     return $child;
 }
開發者ID:artre,項目名稱:study,代碼行數:25,代碼來源:frame.cls.php

示例2: recursiveStripQuotes

function recursiveStripQuotes(DOMNode $node)
{
    if (!$node->childNodes) {
        return;
    }
    $purge = array();
    foreach ($node->childNodes as $child) {
        $class = null;
        if ($child->attributes) {
            $class = $child->attributes->getNamedItem('class');
        }
        if ($class && $class->value == 'quoteheader') {
            $purge[] = $child;
        } elseif ($class && $class->value == 'quotefooter') {
            $purge[] = $child;
        } elseif ($child->nodeName == 'blockquote') {
            $purge[] = $child;
        } else {
            recursiveStripQuotes($child);
        }
    }
    foreach ($purge as $child) {
        $node->removeChild($child);
    }
    return $node;
}
開發者ID:ErikRoelofs,項目名稱:wordcounter,代碼行數:26,代碼來源:index.php

示例3: delete

 /**
  * Delete a file from the list.
  *
  * @param string $file The file name.
  *
  * @return NULL
  */
 public function delete($file)
 {
     $this->_dir_list->deleteFile($file);
     if (isset($this->_install_list[$file])) {
         $this->_xml->removeWhitespace($this->_install_list[$file]->nextSibling);
         $this->_filelist->removeChild($this->_install_list[$file]);
     }
 }
開發者ID:horde,項目名稱:horde,代碼行數:15,代碼來源:Contents.php

示例4: mobilize_remove_element

function mobilize_remove_element(DOMNode $link)
{
    // Move all link tag content to its parent node just before it.
    while ($link->hasChildNodes()) {
        $child = $link->removeChild($link->firstChild);
        $link->parentNode->insertBefore($child, $link);
    }
    // Remove the link tag.
    $link->parentNode->removeChild($link);
}
開發者ID:madeny,項目名稱:cartapi-plugin-prestashop,代碼行數:10,代碼來源:mobilize.php

示例5: removeCharacterDataNodes

 private static function removeCharacterDataNodes(\DOMNode $node)
 {
     $node->normalize();
     if ($node->hasChildNodes()) {
         for ($i = $node->childNodes->length - 1; $i >= 0; $i--) {
             $child = $node->childNodes->item($i);
             if ($child instanceof \DOMCharacterData) {
                 if (!strlen(trim($child->data))) {
                     $node->removeChild($child);
                 }
             }
         }
     }
 }
開發者ID:goetas,項目名稱:webservices,代碼行數:14,代碼來源:AbstractXmlTest.php

示例6: setContent

 /**
  * nastavi obsah item
  * @param string $value
  */
 public function setContent($value)
 {
     try {
         if (htmlspecialchars($value) == $value && htmlspecialchars_decode($value) == $value) {
             $this->node->nodeValue = $value;
         } else {
             foreach ($this->node->childNodes as $nodeChild) {
                 $this->node->removeChild($nodeChild);
             }
             $this->node->appendChild($this->config->getDom()->createCDATASection($value));
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
開發者ID:palmic,項目名稱:lbox,代碼行數:19,代碼來源:abstract.LBoxConfigItem.php

示例7: setNodeContent

 /**
  * Set the contents of a DOMNode.
  *
  * @param \DOMNode $node
  *   A DOMNode object.
  * @param string $content
  *   The text or HTML that will replace the contents of $node.
  */
 protected function setNodeContent(\DOMNode $node, $content)
 {
     // Remove all children of the DOMNode.
     while ($node->hasChildNodes()) {
         $node->removeChild($node->firstChild);
     }
     if (strlen($content)) {
         // Load the contents into a new DOMDocument and retrieve the elements.
         $replacement_nodes = Html::load($content)->getElementsByTagName('body')->item(0);
         // Finally, import and append the contents to the original node.
         foreach ($replacement_nodes->childNodes as $replacement_node) {
             $replacement_node = $node->ownerDocument->importNode($replacement_node, TRUE);
             $node->appendChild($replacement_node);
         }
     }
 }
開發者ID:nB-MDSO,項目名稱:mdso-d8blog,代碼行數:24,代碼來源:DomHelperTrait.php

示例8: visitProperty

 protected function visitProperty(PropertyMetadata $metadata, $data, Context $context)
 {
     $v = $metadata->getValue($data);
     if ($metadata->xmlAttribute) {
         $attributeName = $this->namingStrategy->translateName($metadata);
         $this->currentNodes = $this->document->createElement('tmp');
         $context->accept($v, $metadata->type);
         $node = $this->createAttributeNode($metadata, $attributeName);
         $node->appendChild($this->createTextNode((string) $this->currentNodes->nodeValue));
         return $this->currentNodes = $node;
     }
     if ($metadata->xmlValue) {
         $this->currentNodes = $this->document->createElement('tmp');
         $context->accept($v, $metadata->type);
         $node = $this->currentNodes->childNodes->item(0);
         $this->currentNodes->removeChild($node);
         return $this->currentNodes = $node;
     }
     if ($metadata->xmlAttributeMap) {
         $attributes = [];
         foreach ($v as $key => $value) {
             $node = $this->createAttributeNode($metadata, $key);
             $node->appendChild($this->createTextNode((string) $value));
             $attributes[] = $node;
         }
         return $this->currentNodes = $attributes;
     }
     if (null === $v && !$context->shouldSerializeNull()) {
         return $this->currentNodes = null;
     }
     $elementName = $this->namingStrategy->translateName($metadata);
     $this->currentNodes = $this->createElement($metadata->xmlNamespace, $elementName);
     $context->accept($v, $metadata->type);
     if (is_object($v) && null !== $v && !$metadata instanceof AdditionalPropertyMetadata && $context->isVisiting($v)) {
         return $this->currentNodes = null;
     }
     if ($metadata->xmlCollectionInline || $metadata->inline) {
         $children = iterator_to_array($this->currentNodes->childNodes);
         foreach ($children as $childNode) {
             $this->currentNodes->removeChild($childNode);
         }
         $this->currentNodes = $children;
     }
     return $this->currentNodes;
 }
開發者ID:alekitto,項目名稱:serializer,代碼行數:45,代碼來源:XmlSerializationVisitor.php

示例9: emptyNodeContent

 public static function emptyNodeContent(DOMNode $oNode)
 {
     while ($oNode->childNodes->length > 0) {
         $oNode->removeChild($oNode->childNodes->item(0));
     }
 }
開發者ID:posib,項目名稱:posib-legacy,代碼行數:6,代碼來源:dom_parser.php

示例10: deleteElement

 /**
  * Delete document child element
  *
  * @param OpenDocument_Element $element
  * @access public
  */
 public function deleteElement(OpenDocument_Element $element)
 {
     $this->cursor->removeChild($element->getNode());
     unset($element);
 }
開發者ID:ookwudili,項目名稱:chisimba,代碼行數:11,代碼來源:OpenDocument.php

示例11: removeChilds

 public static function removeChilds(\DOMNode $ref)
 {
     while ($ref->hasChildNodes()) {
         $ref->removeChild($ref->firstChild);
     }
 }
開發者ID:goetas,項目名稱:twital,代碼行數:6,代碼來源:DOMHelper.php

示例12: removeChildsByName

 /**
  * Удалить из дерева элементов все элементы, у которых
  * локальное имя соответствует указанному
  *
  * @param DOMNode $node
  * @param $name
  * @return DOMNode
  */
 private function removeChildsByName(DOMNode $node, $name)
 {
     if ($node->hasChildNodes()) {
         foreach ($node->childNodes as $child) {
             if ($child->localName == $name) {
                 $node->removeChild($child);
             } else {
                 $this->removeChildsByName($child, $name);
             }
         }
     }
     return $node;
 }
開發者ID:Rustam44,項目名稱:ASUPortalPHP,代碼行數:21,代碼來源:CPrintController.class.php

示例13: appendXml

 /**
  * Appends the xml structure with our values.
  *
  * @param \DOMNode $node
  * @param boolean $printDefaults
  * @param bool $printComments
  * @return \DOMElement
  * @throws \Exception
  */
 public function appendXml(\DOMNode $node, $printDefaults = false, $printComments = false)
 {
     $doc = $node instanceof \DOMDocument ? $node : $node->ownerDocument;
     if ($printComments) {
         $this->lastRootElementComment = $doc->createComment($this->docBlock);
         $node->appendChild($this->lastRootElementComment);
     }
     try {
         $rootNode = $doc->createElement($this->rootName);
         $node->appendChild($rootNode);
     } catch (\DOMException $e) {
         throw new \Exception(sprintf('Can not create xml element `%s`', $this->rootName), 0, $e);
     }
     foreach ($this as $key => $val) {
         $this->appendXmlProperty($key, $rootNode, $printDefaults, $printComments);
     }
     foreach ($this->additionalNodes as $k => $v) {
         $this->appendXmlValue($k, $v, $rootNode, $printDefaults, $printComments);
     }
     foreach ($this->additionalAttributes as $k => $v) {
         $rootNode->setAttribute($k, (string) $v);
     }
     if ($this->lastRootElementComment && !$this->lastRootElementComment->substringData(0, 1)) {
         $node->removeChild($this->lastRootElementComment);
     }
     return $rootNode;
 }
開發者ID:jarves,項目名稱:jarves,代碼行數:36,代碼來源:Model.php

示例14: removeBlackNodes

 protected function removeBlackNodes(\DOMNode $node, array $blackList)
 {
     foreach ($blackList as $blackNode) {
         $node->removeChild($blackNode);
     }
     return $node;
 }
開發者ID:behzadsh,項目名稱:falcon-search,代碼行數:7,代碼來源:ProcessNodes.php

示例15: applyTagReplaceContent

 /**
 	Perform a "replaceContent" operation.
 
 	@param $oAction		The taconite action.
 	@param $oElement	The document element.
 */
 protected function applyTagReplaceContent(DOMNode $oAction, DOMNode $oElement)
 {
     foreach ($oElement->childNodes as $oChild) {
         $oElement->removeChild($oChild);
     }
     $this->applyTagAppend($oAction, $oElement);
 }
開發者ID:extend,項目名稱:wee,代碼行數:13,代碼來源:weeTaconite.class.php


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