New issue
Have a question about this project? Sign up for a free GitHub account to open 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
How do i remove certain tags/nodes before selecting a text? #26
Comments
The |
@causal-agent Is it possible to exclude all children of the node for traversal / getting its text? |
@Boscop have the same issue right now...:-) |
@Boscop, For markup like this:
I wrote following code to extract 333:
I can also use last '>' symbol as base. P.S. I'd also like to have such feature in library itself though... |
@causal-agent Hi! Could you suggest any possibilities to do inner_text method like for example in jquery using html5ever? I can probably help with implementation...Just this html5ever is absolute dark forest for me... |
just use ElementRef to get child text node. let only_self_text = doc
.select(&Selector::parse("button > span").unwrap())
.next()
.and_then(|item| item.first_child())
.and_then(|t| t.value().as_text())
.map(|t| t.text.to_string())
.unwrap_or_default(); |
When we have few tags that need to be removed before selecting a tag for example
Output
["\n Hello World\n ", "\n {\"test\":\"json\"}\n ", "\n \n"]
The output will have the value from the script tags, Is there any way we can remove those?
The text was updated successfully, but these errors were encountered: