childNodes as $node) { if ($node->nodeType === XML_ELEMENT_NODE) { $newList->add($node); } } return $newList; } /** * Returns the Element immediately prior to the specified one in its parent's children list, or null if the specified element is the first one in the list. * * @see https://wiki.php.net/rfc/dom_living_standard_api * @return DOMElement|null */ public function previousElementSibling() { $previous = $this->previousSibling; do { if ($previous->nodeType === XML_ELEMENT_NODE) { return $previous; } } while ($previous = $previous->previousSibling); return null; } }