You are here

protected static function PHPUnit_Util_XML::getNodeText in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpunit/phpunit/src/Util/XML.php \PHPUnit_Util_XML::getNodeText()

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

@since Method available since Release 3.3.0

Parameters

DOMNode $node:

Return value

string

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

File

vendor/phpunit/phpunit/src/Util/XML.php, line 887

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);
}