diff --git a/src/XML/ds/KeyInfo.php b/src/XML/ds/KeyInfo.php
index e33f2a1b..1c013590 100644
--- a/src/XML/ds/KeyInfo.php
+++ b/src/XML/ds/KeyInfo.php
@@ -13,6 +13,7 @@
 use SimpleSAML\XML\XsNamespace as NS;
 use SimpleSAML\XMLSecurity\Constants as C;
 use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;
+use SimpleSAML\XMLSecurity\XML\ds\AbstractDsElement;
 
 /**
  * Class representing a ds:KeyInfo element.
@@ -53,7 +54,7 @@ public function __construct(
         Assert::nullOrValidNCName($Id);
 
         foreach ($info as $item) {
-            if ($item->getNamespaceURI() === static::NS) {
+            if ($item instanceof AbstractDsElement) {
                 Assert::isInstanceOfAny(
                     $item,
                     [KeyName::class, KeyValue::class, RetrievalMethod::class, X509Data::class],