code: protected function scanElementForText(\DOMNode $element)
      {
          $str = '';
          foreach ($element->childNodes as $child) {
              /** @var \DOMNode $child */
              if ($child->nodeType == XML_TEXT_NODE) {
                  $str .= $child->nodeValue;
              } elseif ($child->nodeType == XML_ELEMENT_NODE && $child->nodeName == 'text:s') {
                  // It's a space
  
                  // Multiple spaces?
                  /** @var \DOMAttr $cAttr */
                  $cAttr = $child->attributes->getNamedItem('c');
                  if ($cAttr) {
                      $multiplier = (int) $cAttr->nodeValue;
                  } else {
                      $multiplier = 1;
                  }
  
                  $str .= str_repeat(' ', $multiplier);
              }
  
              if ($child->hasChildNodes()) {
                  $str .= $this->scanElementForText($child);
              }
          }
  
          return $str;
      }
docs: Recursively scan element.
  
  @param \DOMNode $element
  
  @return string