diff --git a/lib/IdPAccountManager/SAMLMetadata.pm b/lib/IdPAccountManager/SAMLMetadata.pm
index 7fb170ce2225a695c7848152087cef8980eb21d1..06e16fa8baabe0da038be28c579131d2625b0344 100644
--- a/lib/IdPAccountManager/SAMLMetadata.pm
+++ b/lib/IdPAccountManager/SAMLMetadata.pm
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use English qw(-no_match_vars);
-use XML::LibXML;
+use XML::LibXML qw(:libxml);
 
 use IdPAccountManager::Tools;
 
@@ -58,7 +58,7 @@ sub parse {
         foreach my $child ($EntityDescriptor->childNodes()) {
 
             ## Ignoringnodes of type XML::LibXML::Text or XML::LibXML::Comment
-            next unless (ref($child) =~ /^XML::LibXML::Element/);
+            next unless $child->nodeType() == XML_ELEMENT_NODE;
 
             if ($child->nodeName =~ /IDPSSODescriptor$/) {