diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php
index b43fe49a76eccb329d6fa83bd321f3578287ca97..fb05d51bf7698fa495bb2e85d6ff95788343469f 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 or !is_array($result)) {
+        if (!($result || !is_array($result))) {
             if ($required) {
                 throw new \Exception('Could not get value from XML document using the following XPath expression: ' . $xpath);
             } else {