Helpers

getElementByXpath.mjs

@mr_ozio/scraper-utils · v2.5.0 · Generated April 21, 2026

Target Style

Target Style

1 exports

const

findElement

Target Style
export const findElement = ({ xpath }) =>

Finds the first DOM element matching an XPath expression using named options.

Target style API. Preferred for new code.

Parameters

  • options{ xpath: string }

Returns

Node | null

Legacy Style

Legacy Style

1 exports

const

getElementByXpath

Legacy Style
export const getElementByXpath = (path) => findElement({ xpath: path })

Finds the first DOM element matching an XPath expression.

Legacy API. Kept for older code and not the preferred choice for new code.

Parameters

  • pathstring

Returns

Node | null