DOMXPath
class DOMXPath (View source)
The DOMXPath class (supports XPath 1.0)
Properties
| DOMDocument | $document | ||
| $registerNodeNamespaces |
Methods
Registers the namespace with the
Register PHP functions as XPath functions
Register a PHP functions as namespaced XPath function
Quotes a string for use in an XPath expression
Details
__construct(DOMDocument $document, bool $registerNodeNS = true)
Creates a new
bool
registerNamespace(string $prefix, string $namespace)
Registers the namespace with the
mixed
query(string $expression, DOMNode $contextNode = null, bool $registerNodeNS = true)
Evaluates the given XPath expression
mixed
evaluate(string $expression, DOMNode $contextNode = null, bool $registerNodeNS = true)
Evaluates the given XPath expression and returns a typed result if possible.
void
registerPhpFunctions(string|string[] $restrict = null)
Register PHP functions as XPath functions
void
registerPhpFunctionNS(string $namespaceURI, string $name, callable $callable)
Register a PHP functions as namespaced XPath function
This method enables the ability to use a PHP function as a namespaced XPath function inside XPath expressions.
static string
quote(string $str)
Quotes a string for use in an XPath expression
Quotes str for use in an XPath expression.