本文整理汇总了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例6: setText
function setText(DOMElement $el, $textcontent)
{
while ($el->firstChild) {
$el->removeChild($el->firstChild);
}
if (strlen($textcontent)) {
$el->appendChild($el->ownerDocument->createTextNode($textcontent));
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}