Method
xpath(_:namespaces:defaultPrefix:)
Compiles an XPath expression using namespace declarations from the document.
func xpath(_ path: String, namespaces ns: AnySequence<XMLNameSpace> = emptySequence(), defaultPrefix: String = "ns") -> XMLPath?
Parameters
path-
The XPath expression to compile.
ns-
The namespace declarations to register in the XPath context.
defaultPrefix-
The prefix to use for default namespace declarations.
Return Value
A compiled XPath result, or nil when context creation or evaluation fails.
Discussion
Supply namespaces taken from the parsed tree when the expression refers to prefixed or default namespaces. A fallback prefix is registered for namespace declarations that do not carry an explicit prefix.