diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php
index fb05d51bf7698fa495bb2e85d6ff95788343469f..b8dda85226cccc11fd715fefa9e2fb9b01796535 100644
--- a/lib/SimpleSAML/XML/Parser.php
+++ b/lib/SimpleSAML/XML/Parser.php
@@ -50,7 +50,7 @@ class Parser
     public function getValue($xpath, $required = false)
     {
         $result = $this->simplexml->xpath($xpath);
-        if (!($result || !is_array($result))) {
+        if (!is_array($result) || empty($result)) {
             if ($required) {
                 throw new \Exception('Could not get value from XML document using the following XPath expression: ' . $xpath);
             } else {