diff --git a/lib/SimpleSAML/XML/SAML20/AuthnResponse.php b/lib/SimpleSAML/XML/SAML20/AuthnResponse.php
index 690eab1f732ea783f442c4134caff1429f5393f8..db76521b96aae4e2a0ba003fc3fba043e2043dc7 100644
--- a/lib/SimpleSAML/XML/SAML20/AuthnResponse.php
+++ b/lib/SimpleSAML/XML/SAML20/AuthnResponse.php
@@ -358,12 +358,13 @@ class SimpleSAML_XML_SAML20_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 		$xPath = new DOMXpath($dom);
 		$xPath->registerNamespace('samlp', self::SAML2_PROTOCOL_NS);
 
-		$result = $xPath->query('/samlp:Response/@InResponseTo');
-		if($result->length === 0) {
+		$query = 'string(/samlp:Response/@InResponseTo)';
+		$result = $xPath->evaluate($query);
+		if($result === '') {
 			return NULL;
 		}
 
-		return $result->item(0)->value;
+		return $result;
 	}