XML DOM createExpression() method

Document object reference manual

Definition and usage

The createExpression() method creates an XPath expression for later calculation.

Syntax:

createExpression(xpathText,namespaceURLMapper)
Parameter Description
xpathText A string representing the XPath expression to be compiled.
namespaceURLMapper a function that maps a namespace prefix to a full namespace URL. If such a mapping is not needed, it is null.

return value

a XPathExpression object.

throw

If xpathText Contains a syntax error, or it uses namespaceURLMapper A namespace prefix that cannot be resolved, this method will throw an exception.

Description

This method accepts a string representing an XPath expression and converts it into a compiled expression, that is, an XPathExpression. In addition to this expression, this method also accepts a function in the form of function(prefix), which parses a namespace prefix string and returns a full namespace URL string.

IE does not support this API. See Node.selectNodes() Learn a specific alternative method for IE.

Document object reference manual