From 7fb71be648c534491bf1f0b61f8ca53484618c1c Mon Sep 17 00:00:00 2001 From: Tim van Dijen Date: Wed, 24 Jul 2024 17:10:58 +0200 Subject: [PATCH] Normalize elements by dropping their parent objects --- src/AbstractElement.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/AbstractElement.php b/src/AbstractElement.php index b9cd3e5..7e5d3c8 100644 --- a/src/AbstractElement.php +++ b/src/AbstractElement.php @@ -230,6 +230,10 @@ public static function getChildrenOfClass(DOMElement $parent): array && $node->namespaceURI === static::getNamespaceURI() && $node->localName === static::getLocalName() ) { + // Normalize the DOMElement by importing it into a clean empty document + $newDoc = DOMDocumentFactory::create(); + $node = $newDoc->appendChild($newDoc->importNode($node, true)); + $ret[] = static::fromXML($node); } }