I am using domCrawler in a symfony framework. I scanned the content from html using it. Now I need to get the text inside the element with the identifier. I can use text using the following code:
$nodeValues = $crawler1->filter('#idOfTheElement')->each(function (Crawler $node, $i) { return $node->text(); });
The element ( #idOfTheElement ) contains some spaces, buttons, etc. (also having some classes). I do not want the contents inside them. How to get text from an element, with the exception of some other elements inside.
Note. The text I wanted to receive has no other shell except the #idOfTheElement element
The html is as follows:
<li id='#idOfTheElement'>Tel :<button data-pjtooltip="{dtanchor:'tooltipOpposeMkt'}" class="noMkt JS_PJ" type="button">text :</button><dl><dt><a name="tooltipOpposeMkt"></a></dt><dd><div class="wrapper"><p><strong>Signification des pictogrammes</strong></p><p>Devant un numéro, le picto <img width="11" height="9" alt="" src="something"> signale une opposition aux opérations de marketing direct.</p><span class="arrow"> </span></div></dd></dl>12 23 45 88 99</li>
source share