function Crawler::innerText
Returns only the inner text that is the direct descendent of the current node, excluding any child nodes.
Parameters
bool $normalizeWhitespace Whether whitespaces should be trimmed and normalized to single spaces:
File
-
vendor/
symfony/ dom-crawler/ Crawler.php, line 571
Class
- Crawler
- Crawler eases navigation of a list of \DOMNode objects.
Namespace
Symfony\Component\DomCrawlerCode
public function innerText(bool $normalizeWhitespace = true) : string {
foreach ($this->getNode(0)->childNodes as $childNode) {
if (\XML_TEXT_NODE !== $childNode->nodeType && \XML_CDATA_SECTION_NODE !== $childNode->nodeType) {
continue;
}
if (!$normalizeWhitespace) {
return $childNode->nodeValue;
}
if ('' !== trim($childNode->nodeValue)) {
return $this->normalizeWhitespace($childNode->nodeValue);
}
}
return '';
}