DOMParentNode¶
DOMParentNode is an interface introduced in PHP 8.0 for DOM nodes that can have children. It is implemented by DOMDocument, DOMElement, and DOMDocumentFragment.
It provides prepend() and append() methods to insert nodes as first or last children, and childElementCount, firstElementChild, lastElementChild properties.
<?php
$dom = new DOMDocument;
$dom->loadHTML('<p>Hello</p>');
$p = $dom->getElementsByTagName('p')->item(0);
$p->append($dom->createTextNode(' world'));
?>
See also DOMParentNode Class and DOMChildNode Class.
Related : Document Object Model (DOM), Interface, , PHP Native Interfaces, SplSubject
Added in PHP 8.0