Searchable
public protocol Searchable
Instances of conforming types can use XPath or CSS selectors to form a search request.
-
Searches for a node from a current node by provided XPath.
Declaration
Swift
func search(byXPath xpath: String, namespaces: [String : String]?) -> XPathResultParameters
xpathXPath to search by.
namespacesXML namespace to search in. Default value is
nil.Return Value
XPathResultenum case with an associated value. -
element(atXPath:namespaces:)Default implementationSearches for a node from a current node by provided XPath and returns the first match.
Default Implementation
Searches for a node from a current node by provided XPath and returns the first match.
Declaration
Swift
func element(atXPath xpath: String, namespaces: [String : String]?) -> XMLElement?Parameters
xpathXPath to search by.
namespacesXML namespace to search in. Default value is
nil.Return Value
The first element matching given XPath.
nilif XPath does not contain any nodes. -
Searches for a node from a current node by provided CSS selector.
Declaration
Swift
func search(byCSSSelector selector: String, namespaces: [String : String]?) -> XPathResultParameters
selectorCSS selector to search by.
namespacesXML namespace to search in. Default value is
nil.Return Value
XPathResultenum case with an associated value. -
element(atCSSSelector:namespaces:)Default implementationSearches for a node from a current node by provided CSS selector and returns the first match.
Default Implementation
Searches for a node from a current node by provided CSS selector and returns the first match.
Declaration
Swift
func element(atCSSSelector selector: String, namespaces: [String : String]?) -> XMLElement?Parameters
selectorCSS selector to search by.
namespacesXML namespace to search in. Default value is
nil.Return Value
The first element matching given selector.
nilif corresponding XPath does not contain any nodes.
-
search(byXPath:)Extension methodSearches for a node from a current node by provided XPath.
Declaration
Swift
public final func search(byXPath xpath: String) -> XPathResultParameters
xpathXPath to search by.
Return Value
XPathResultenum case with an associated value. -
element(atXPath:)Extension methodSearches for a node from a current node by provided XPath and returns the first match.
Declaration
Swift
public final func element(atXPath xpath: String) -> XMLElement?Parameters
xpathXPath to search by.
Return Value
The first element matching given XPath.
nilif XPath does not contain any nodes. -
search(byCSSSelector:)Extension methodSearches for a node from a current node by provided CSS selector.
Declaration
Swift
public final func search(byCSSSelector selector: String) -> XPathResultParameters
selectorCSS selector to search by.
Return Value
XPathResultenum case with an associated value. -
element(atCSSSelector:)Extension methodSearches for a node from a current node by provided CSS selector and returns the first match.
Declaration
Swift
public final func element(atCSSSelector selector: String) -> XMLElement?Parameters
selectorCSS selector to search by.
Return Value
The first element matching given selector.
nilif corresponding XPath does not contain any nodes.
Searchable Protocol Reference