protected static function PHPUnit_Util_XML::getNodeText

Get the text value of this node's child text node.

@since Method available since Release 3.3.0 @author Mike Naberezny <mike@maintainable.com> @author Derek DeVries <derek@maintainable.com>

Parameters

DOMNode $node:

Return value

string

1 call to PHPUnit_Util_XML::getNodeText()
PHPUnit_Util_XML::findNodes in drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/XML.php
Parse out the options from the tag using DOM object tree.

File

drupal/core/vendor/phpunit/phpunit/PHPUnit/Util/XML.php, line 901

Class

PHPUnit_Util_XML
XML helpers.

Code

protected static function getNodeText(DOMNode $node) {
  if (!$node->childNodes instanceof DOMNodeList) {
    return '';
  }
  $result = '';
  foreach ($node->childNodes as $childNode) {
    if ($childNode->nodeType === XML_TEXT_NODE || $childNode->nodeType === XML_CDATA_SECTION_NODE) {
      $result .= trim($childNode->data) . ' ';
    }
    else {
      $result .= self::getNodeText($childNode);
    }
  }
  return str_replace('  ', ' ', $result);
}