Skip to main content

find_all

Function find_all 

Source
pub fn find_all(doc: &Document, selector: &str) -> QueryResult<Vec<NodeId>>
Expand description

Finds all elements matching a CSS selector.

§Errors

Returns [QueryError::InvalidSelector] if the selector syntax is invalid.

§Examples

use scrape_core::{Html5everParser, Parser, query::find_all};

let parser = Html5everParser;
let doc = parser.parse("<ul><li>A</li><li>B</li><li>C</li></ul>").unwrap();

let items = find_all(&doc, "li").unwrap();
assert_eq!(items.len(), 3);