Selector for nodes
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 https://github.com/w3c/csswg-drafts/issues/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.
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, hi, hi2.
Seems the selector do not support the selector.
Thx!