CSS selector and XPath engine for the SIMD-optimized HTML parser.
Provides CSS selector parsing, XPath evaluation, and a convenience API
for querying a parsed [fhp_tree::Document].
Quick Start — CSS
use parse;
use Selectable;
let doc = parse.unwrap;
let sel = doc.select.unwrap;
assert_eq!;
assert_eq!;
Quick Start — XPath
use parse;
use Selectable;
use XPathResult;
let doc = parse.unwrap;
let result = doc.xpath.unwrap;
match result
Supported CSS Selectors
- Type:
div,p,span - Class:
.class - ID:
#id - Universal:
* - Attribute:
[attr],[attr=val],[attr~=val],[attr^=val],[attr$=val],[attr*=val] - Pseudo:
:first-child,:last-child,:nth-child(an+b),:not(sel) - Compound:
div.class#id[attr] - Combinator:
A B,A > B,A + B,A ~ B - Comma list:
div, span
Supported XPath
//tag— descendant search//tag[@attr='value']— attribute predicate/path/to/tag— absolute path//tag[contains(@attr, 'substr')]— contains predicate//tag[position()=N]— position predicate//tag/text()— text extraction..— parent axis