Skip to content

Commit 2bb60e5

Browse files
committed
Bugfix: skip non-elements
1 parent 2b37da9 commit 2bb60e5

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/XML/DOMDocumentFactory.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,12 @@ public static function normalizeDocument(Dom\XMLDocument $doc): Dom\XMLDocument
109109

110110
// Register all namespaces to ensure XPath can handle them
111111
foreach ($xpath->query('//*[namespace::*]') as $node) {
112-
$name = 'xmlns:' . $node->prefix;
113-
// Both prefix and namespaceURI NULL equals the default xmlns:xml namespace
114-
if ($node->prefix !== null && $node->namespaceURI !== null) {
115-
$xmlnsAttributes[$name] = $node->namespaceURI;
112+
if ($node instanceof Dom\Element) {
113+
$name = 'xmlns:' . $node->prefix;
114+
// Both prefix and namespaceURI NULL equals the default xmlns:xml namespace
115+
if ($node->prefix !== null && $node->namespaceURI !== null) {
116+
$xmlnsAttributes[$name] = $node->namespaceURI;
117+
}
116118
}
117119
}
118120

0 commit comments

Comments
 (0)