diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php
index 49a41e974d2377187f328e96bb07afa155572f7d..a5885b7c116a2d9377a03160445d9dca8be35025 100644
--- a/lib/SimpleSAML/Metadata/SAMLParser.php
+++ b/lib/SimpleSAML/Metadata/SAMLParser.php
@@ -1157,7 +1157,7 @@ class SimpleSAML_Metadata_SAMLParser {
 			if(!$element->hasAttribute('index')) {
 				throw new Exception($name . ' missing required index attribute.');
 			}
-			$ep['index'] = $element->getAttribute('index');
+			$ep['index'] = (int)$element->getAttribute('index');
 
 			if($element->hasAttribute('isDefault')) {
 				$t = $element->getAttribute('isDefault');