I want to exclude only the JavaScript tag contents when retrieving only the text of the body element in XPath
▼index.html
<body>
I want to acquire only "text excluding HTML tag" included in this part.
<script language="JavaScript" type="text/javascript">
var foo = 42;
</script>
</body>
I have created the following code with DomCrawler. But, because it contains JavaScript tag contents, I could not get the intended results..
<?php
$crawler->filterXPath('//body')->each(function (DomCrawler $node) use ($url) {
$result = trim($node->text());
});