-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Get direct descendent text only when calling text() on a node. #42294
New issue
Have a question about this project? Sign up for a free GitHub account to o 8000 pen an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
|
And what if you don't know XPath and rely on |
Not that I am aware of. In any case, there's nothing we can do here in the codebase about it. So I am closing here. Thank you for understanding. |
But I don't understand. Why is there nothing that can be done? |
What solution do you see if CSS doesn't allow to filter the particular node exclusively? |
Either a parameter or method that only returns the direct decedent text node, e.g. |
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [DomCrawler] Added Crawler::innerText() method | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #42294 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Adds a method to get the inner text that is directly descended from the current node only, ignoring text nodes in any child nodes. Commits ------- 4767694 [DomCrawler] Added Crawler::innerText() method
Description
Get direct descendent text only when calling
text()
on a node.Example
When an HTML node contains mixed text and element nodes, it is difficult to get just the text of the current node, since the
text()
call will also recursively parse all descendents.When we have a
Crawler
instance pointing at<foo>
, callingtext()
will returnfoo bar
. There is no way to get just the direct descendent text node,foo
.The text was updated successfully, but these errors were encountered: