本文整理汇总了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;
}
示例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;
}
示例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]);
}
}
示例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);
}
示例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);
}
}
}
}
}
示例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;
}
}
示例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);
}
}
}
示例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;
}
示例9: emptyNodeContent
public static function emptyNodeContent(DOMNode $oNode)
{
while ($oNode->childNodes->length > 0) {
$oNode->removeChild($oNode->childNodes->item(0));
}
}
示例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);
}
示例11: removeChilds
public static function removeChilds(\DOMNode $ref)
{
while ($ref->hasChildNodes()) {
$ref->removeChild($ref->firstChild);
}
}
示例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;
}
示例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;
}
示例14: removeBlackNodes
protected function removeBlackNodes(\DOMNode $node, array $blackList)
{
foreach ($blackList as $blackNode) {
$node->removeChild($blackNode);
}
return $node;
}
示例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);
}