Document.createExpression()

This method compiles an XPathExpression which can then be used for (repeated) evaluations.

Syntax

xpathExpr = document.createExpression(xpathText, namespaceURLMapper);

Parameters

  • xpathText is a string which is the XPath expression to be compiled.
  • namespaceURLMapper is a function which maps a namespace prefix to a namespace URL (or null if none needed).

Firefox 3 note

Prior to Firefox 3, you could call this method on documents other than the one you planned to run the XPath against. Under Firefox 3, you must call it on the same document.

Return value

XPathExpression

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
createExpressionChrome Full support 1Edge Full support 12Firefox Full support YesIE ? Opera ? Safari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android ? Safari iOS ? Samsung Internet Android Full support Yes

Legend

Full support
Full support
Compatibility unknown
Compatibility unknown

See also