Skip to main content

css_to_xpath

Function css_to_xpath 

Source
pub fn css_to_xpath(
    css: &str,
    prefix: &str,
    mode: Mode,
) -> Result<String, Error>
Expand description

Translate a CSS selector to an XPath 1.0 expression.

§Arguments

  • css — A CSS selector string.
  • prefix — An XPath path prefix prepended verbatim to each selector-group branch, so it must end in something a node test can follow: an axis (DESCENDANT_OR_SELF) or a step separator (WHOLE_DOCUMENT). Pass "" for a bare relative expression. Nothing validates it — "/html/body " yields /html/body div, which XPath reads as a division, not a path. A selector group anchored on :scope ignores prefix and anchors on self:: instead.
  • mode — The translator flavour: Mode::Generic, Mode::Html, or Mode::Xhtml.

§Errors

Returns an Error when the selector is syntactically invalid or uses an unsupported construct.