diff --git a/lib/SAML2/XML/saml/AttributeValue.php b/lib/SAML2/XML/saml/AttributeValue.php
index 5351e999af43f344802669a59561f3316f9719dd..bc890559260d34be7868996613d6964a21eb23c4 100644
--- a/lib/SAML2/XML/saml/AttributeValue.php
+++ b/lib/SAML2/XML/saml/AttributeValue.php
@@ -68,6 +68,13 @@ class SAML2_XML_saml_AttributeValue {
 		return $v;
 	}
 
+	/*
+	 * Returns a plain text content of the attribute value.
+	 */
+	public function getString() {
+		return $this->element->textContent;
+	}
+
 
 	/**
 	 * Convert this attribute value to a string.
diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php
index e27baf13873da00110829030ffdd8fd8a6338bf5..e81732999fed5d971a7b56dc4490022b225bf876 100644
--- a/lib/SimpleSAML/Metadata/SAMLParser.php
+++ b/lib/SimpleSAML/Metadata/SAMLParser.php
@@ -904,7 +904,9 @@ class SimpleSAML_Metadata_SAMLParser {
 							}
 							
 							$values = array();
-							foreach($attr->AttributeValue AS $attrvalue) $values[] = (string) $attrvalue;
+							foreach($attr->AttributeValue AS $attrvalue) {
+								$values[] = $attrvalue->getString();
+							}
 
 							$ret['EntityAttributes'][$name] = $values;
 						}