当前位置: 首页>>代码示例>>PHP>>正文


PHP DOMElement::removeChild方法代码示例

本文整理汇总了PHP中DOMElement::removeChild方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMElement::removeChild方法的具体用法?PHP DOMElement::removeChild怎么用?PHP DOMElement::removeChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DOMElement的用法示例。


在下文中一共展示了DOMElement::removeChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: removeDocumentChildElementsByName

 private function removeDocumentChildElementsByName($name)
 {
     $nodes = $this->xpath->query('/phpunit/' . $name);
     foreach ($nodes as $node) {
         $this->rootElement->removeChild($node);
     }
 }
开发者ID:shadowhand,项目名称:humbug,代码行数:7,代码来源:XmlConfiguration.php

示例2: insertTemplateLogic

 public static function insertTemplateLogic($search, $path, \DOMElement $node)
 {
     $template = $node->ownerDocument;
     $node->setAttribute('xml:space', 'preserve');
     // fix whitespaces in mixed node
     /** @var $textNode \DOMText */
     foreach ($node->childNodes as $textNode) {
         $nodeValue = $textNode->nodeValue;
         // utf8_decode
         // before [[tag]] after
         $nodeValueParts = explode($search, $nodeValue, 2);
         // fix similar tags in one node
         if (count($nodeValueParts) === 2) {
             $textNode->nodeValue = '';
             // reset
             // text before
             $before = $template->createTextNode($nodeValueParts[0]);
             $node->insertBefore($before, $textNode);
             // add xsl logic
             $placeholder = $template->createElementNS(self::XSL_NS, 'xsl:value-of');
             $placeholder->setAttribute('select', $path);
             $node->insertBefore($placeholder, $textNode);
             // text after
             $after = $template->createTextNode($nodeValueParts[1]);
             $node->insertBefore($after, $textNode);
             $node->removeChild($textNode);
             return true;
         }
     }
     return false;
 }
开发者ID:noikiy,项目名称:PHPStamp,代码行数:31,代码来源:Processor.php

示例3:

 /**
  * Remove a child frame
  *
  * @param Frame   $child
  * @param boolean $update_node  Whether or not to remove the DOM node
  *
  * @throws DOMPDF_Exception
  * @return Frame The removed child frame
  */
 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:alvarobfdev,项目名称:applog,代码行数:34,代码来源:frame.cls.php

示例4: remove

 /**
  * Removes a rule from this store (must be passed an object, not string/name). Returns TRUE if found.
  * @param Rule|SecurityRule $rule
  * @param bool $deleteForever
  * @return bool
  */
 public function remove($rule, $deleteForever = false)
 {
     $found = false;
     $serial = spl_object_hash($rule);
     if (isset($this->fastMemToIndex[$serial])) {
         $found = true;
         unset($this->fastNameToIndex[$rule->name()]);
         unset($this->rules[$this->fastMemToIndex[$serial]]);
         unset($this->fastMemToIndex[$serial]);
         $this->xmlroot->removeChild($rule->xmlroot);
         $rule->owner = null;
         if ($deleteForever) {
             $rule->cleanForDestruction();
         }
     } elseif ($this->isPreOrPost) {
         if (isset($this->fastMemToIndex_forPost[$serial])) {
             $found = true;
             unset($this->fastNameToIndex_forPost[$rule->name()]);
             unset($this->postRules[$this->fastMemToIndex_forPost[$serial]]);
             unset($this->fastMemToIndex_forPost[$serial]);
             $this->postRulesRoot->removeChild($rule->xmlroot);
             $rule->owner = null;
             if ($deleteForever) {
                 $rule->cleanForDestruction();
             }
         }
     }
     return $found;
 }
开发者ID:shpapy,项目名称:pan-configurator,代码行数:35,代码来源:class-RuleStore.php

示例5: removeChildNode

 /**
  * Remove child node from element.
  *
  * @param $node
  * @return void
  */
 public function removeChildNode($node)
 {
     if (false === $node instanceof \DOMNode) {
         throw new \InvalidArgumentException('Unsupported node type');
     }
     $this->element->removeChild($node);
 }
开发者ID:desmart,项目名称:deform,代码行数:13,代码来源:HtmlNode.php

示例6: setText

function setText(DOMElement $el, $textcontent)
{
    while ($el->firstChild) {
        $el->removeChild($el->firstChild);
    }
    if (strlen($textcontent)) {
        $el->appendChild($el->ownerDocument->createTextNode($textcontent));
    }
}
开发者ID:J-rg,项目名称:ImageOptim,代码行数:9,代码来源:update_appcast.php

示例7: resetDocument

 /**
  * Remove all DOM structures to build new
  */
 public function resetDocument()
 {
     foreach ($this->getElementsByTagName('argument') as $delNode) {
         $this->__rootNode->removeChild($delNode);
     }
     foreach ($this->getElementsByTagName('resourceDescriptor') as $delNode) {
         $this->__rootNode->removeChild($delNode);
     }
     $this->__documentReady = false;
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:13,代码来源:JasperRequestXmlDoc.class.php

示例8: removeSmallTags

 function removeSmallTags(DOMElement $element)
 {
     $subElements = $element->getElementsByTagName("small");
     try {
         foreach ($subElements as $subElement) {
             $element->removeChild($subElement);
         }
     } catch (Exception $e) {
     }
     return $element->getElementsByTagName("small")->length;
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:11,代码来源:leoparser.php

示例9: removeProxyId

 /**
  * @param string $local
  * @param string $remote
  * @return bool
  */
 function removeProxyId($local, $remote)
 {
     foreach ($this->proxys as $index => &$proxy) {
         if ($proxy['local'] == $local && $proxy['remote'] == $remote) {
             unset($this->proxys[$index]);
             $this->proxyIdRoot->removeChild($proxy['xmlroot']);
             return true;
         }
     }
     return false;
 }
开发者ID:shpapy,项目名称:pan-configurator,代码行数:16,代码来源:class-IPsecTunnel.php

示例10: renameTag

 private function renameTag(DOMElement $oldTag, $newTagName)
 {
     $document = $oldTag->ownerDocument;
     $newTag = $document->createElement($newTagName);
     foreach ($oldTag->attributes as $attribute) {
         $newTag->setAttribute($attribute->name, $attribute->value);
     }
     foreach ($oldTag->childNodes as $child) {
         $newTag->appendChild($oldTag->removeChild($child));
     }
     $oldTag->parentNode->replaceChild($newTag, $oldTag);
     return $newTag;
 }
开发者ID:brunopbaffonso,项目名称:ongonline,代码行数:13,代码来源:Menu.php

示例11: getCleanDomTable

 /**
  * @return DOMElement
  * @throws Exception
  */
 private function getCleanDomTable()
 {
     $dom_tables = $this->doc->getElementsByTagNameNS(static::$NS_TABLE, 'table');
     if ($dom_tables->length != 1) {
         throw new Exception("Could not parse ODS template");
     }
     $this->dom_table = $dom_tables->item(0);
     $children = $this->dom_table->childNodes;
     for ($i = $children->length - 1; $i >= 0; $i--) {
         $this->dom_table->removeChild($children->item($i));
     }
     return $this->dom_table;
 }
开发者ID:andi98,项目名称:antragsgruen,代码行数:17,代码来源:OdsTemplateEngine.php

示例12: filterElement

 /**
  * Filter a single element.
  *
  * @param DOMElement $element
  * @return void
  */
 public function filterElement(DOMElement $element)
 {
     $element->setProperty('type', 'footnote');
     $citations = $element->getElementsByTagNameNS(ezcDocumentOdt::NS_ODT_TEXT, 'note-citation');
     // Should be only 1, foreach to remove all
     foreach ($citations as $cite) {
         $attrs = $element->getProperty('attributes');
         if ($attrs === false) {
             $attrs = array();
         }
         $attrs['label'] = $cite->nodeValue;
         $element->setProperty('attributes', $attrs);
         $element->removeChild($cite);
     }
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:21,代码来源:footnote.php

示例13: setAlternativeName

 public function setAlternativeName($newName)
 {
     if ($newName == $this->_alternativeName) {
         return false;
     }
     if ($newName === null || strlen($newName) == 0) {
         $node = DH::findFirstElement('display-name', $this->xmlroot);
         if ($node === false) {
             return false;
         }
         $this->xmlroot->removeChild($node);
         return true;
     }
     $node = DH::findFirstElementOrCreate('display-name', $this->xmlroot);
     DH::setDomNodeText($node, $newName);
     return true;
 }
开发者ID:shpapy,项目名称:pan-configurator,代码行数:17,代码来源:class-VirtualSystem.php

示例14: copyElementInNs

 /**
  * @param \DOMElement $oldElement
  * @param string $newNamespace
  * @return mixed
  */
 public static function copyElementInNs($oldElement, $newNamespace)
 {
     $element = $oldElement->ownerDocument->createElementNS($newNamespace, $oldElement->nodeName);
     // copy attributes
     foreach (iterator_to_array($oldElement->attributes) as $attr) {
         $oldElement->removeAttributeNode($attr);
         if ($attr->namespaceURI) {
             $element->setAttributeNodeNS($attr);
         } else {
             $element->setAttributeNode($attr);
         }
     }
     // copy children
     while ($child = $oldElement->firstChild) {
         $oldElement->removeChild($child);
         $element->appendChild($child);
     }
     $oldElement->parentNode->replaceChild($element, $oldElement);
     return $element;
 }
开发者ID:goetas,项目名称:twital,代码行数:25,代码来源:DOMHelper.php

示例15: setSourcePort

 public function setSourcePort($newPorts)
 {
     if ($newPorts === null || strlen($newPorts) == 0) {
         if (strlen($this->_sport) == 0) {
             return false;
         }
         $this->_sport = $newPorts;
         $sportroot = DH::findFirstElement('source-port', $this->tcpOrUdpRoot);
         if ($sportroot !== false) {
             $this->tcpOrUdpRoot->removeChild($sportroot);
         }
         return true;
     }
     if ($this->_sport == $newPorts) {
         return false;
     }
     if (strlen($this->_sport) == 0) {
         DH::findFirstElementOrCreate('source-port', $this->tcpOrUdpRoot, $newPorts);
         return true;
     }
     $sportroot = DH::findFirstElementOrCreate('source-port', $this->tcpOrUdpRoot);
     DH::setDomNodeText($sportroot, $newPorts);
     return true;
 }
开发者ID:shpapy,项目名称:pan-configurator,代码行数:24,代码来源:class-Service.php


注:本文中的DOMElement::removeChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。