insertAfter XML on PHP, insert element after last child

I’ve been dealing with XML parsing today and I’ve been trying to add an element to the last sibling. The problem is there are no insertAfter() function on PHP, what you need is to get the last sibling and move to the next sibling before inserting your new element.


$lastChild = $searchInterface->lastChild;
$member = $this->doc->createElement('MEMBER_NAME');
$searchInterface->insertBefore($member, $lastChild->nextSibling);