public static function getDOMText(\DOMElement $element) { if (!$element instanceof \DOMElement) { throw new \InvalidArgumentException('Invalid input parameters'); } $txt = ''; for ($i = 0; $i < $element->childNodes->length; $i++) { $child = $element->childNodes->item($i); if (!$child instanceof \DOMText) { throw new \SimpleSAML_Error_Exception($element->localName . ' contained a non-text child node.'); } $txt .= $child->wholeText; } $txt = trim($txt); return $txt; }