-
Notifications
You must be signed in to change notification settings - Fork 113
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
Selector for nodes #209
Comments
So you're asking for a function that returns a Node instead of an ElementRef. What would be the benefit of this? |
mm, how the actual selector would works, if we select a Text element? Text elements are not ElementRef. |
Could you show me the kind of syntax that you would like to achieve? About your question, I would have to try. |
I am closing this for inactivity. Feel free to add a comment / ping me / reopen if needed |
Hi, sorry for being late, here is an example: fn main() {
use scraper::{Html, Selector};
let html = r#"
hi
<p>hi2</p>
"#;
let document = Html::parse_document(html);
let selector = Selector::parse("::target-text").unwrap();
for element in document.select(&selector) {
println!("{}", element.value().name());
}
} Following the docs, I think this should return two nodes, Seems the selector do not support the selector. Thx! |
Hi, actually the select function returns a ElementRef element, which is usually not an issue if we does not have a way to select a Text node, then I found this: https://stackoverflow.com/a/70757577/4652030
For today docs:
https://developer.mozilla.org/en-US/docs/Web/CSS/::target-text
w3c/csswg-drafts#2208
Be able to select Nodes and not just Elements could be a break change for the selector function, or the need of a different one.
This has some issues that are WIP, so I open this just to have this clear.
The text was updated successfully, but these errors were encountered: