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