本文整理汇总了PHP中DOMNode::replaceChild方法的典型用法代码示例。如果您正苦于以下问题:PHP DOMNode::replaceChild方法的具体用法?PHP DOMNode::replaceChild怎么用?PHP DOMNode::replaceChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DOMNode
的用法示例。
在下文中一共展示了DOMNode::replaceChild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doFix
/**
* Run the Fixers on a DOMText content.
*
* @param \DOMText $childNode The node to fix
* @param \DOMNode $node The parent node where to replace the current one
* @param \DOMDocument $dom The Document
*/
private function doFix(\DOMText $childNode, \DOMNode $node, \DOMDocument $dom)
{
$content = $childNode->wholeText;
$current_node = new StateNode($childNode, $node, $dom);
$this->stateBag->setCurrentNode($current_node);
// run the string on all the fixers
foreach ($this->_rules as $fixer) {
$content = $fixer->fix($content, $this->stateBag);
}
// update the DOM only if the node has changed
if ($childNode->wholeText !== $content) {
$new_node = $dom->createTextNode($content);
$node->replaceChild($new_node, $childNode);
// As the node is replaced, we also update it in the StateNode
$current_node->replaceNode($new_node);
}
}