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]?) -> XPathResult

    Parameters

    xpath

    XPath to search by.

    namespaces

    XML namespace to search in. Default value is nil.

    Return Value

    XPathResult enum case with an associated value.

  • element(atXPath:namespaces:) Default implementation

    Searches 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

    xpath

    XPath to search by.

    namespaces

    XML namespace to search in. Default value is nil.

    Return Value

    The first element matching given XPath. nil if 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]?) -> XPathResult

    Parameters

    selector

    CSS selector to search by.

    namespaces

    XML namespace to search in. Default value is nil.

    Return Value

    XPathResult enum case with an associated value.

  • element(atCSSSelector:namespaces:) Default implementation

    Searches 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

    selector

    CSS selector to search by.

    namespaces

    XML namespace to search in. Default value is nil.

    Return Value

    The first element matching given selector. nil if corresponding XPath does not contain any nodes.

  • search(byXPath:) Extension method

    Searches for a node from a current node by provided XPath.

    Declaration

    Swift

    public final func search(byXPath xpath: String) -> XPathResult

    Parameters

    xpath

    XPath to search by.

    Return Value

    XPathResult enum case with an associated value.

  • element(atXPath:) Extension method

    Searches 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

    xpath

    XPath to search by.

    Return Value

    The first element matching given XPath. nil if XPath does not contain any nodes.

  • search(byCSSSelector:) Extension method

    Searches for a node from a current node by provided CSS selector.

    Declaration

    Swift

    public final func search(byCSSSelector selector: String) -> XPathResult

    Parameters

    selector

    CSS selector to search by.

    Return Value

    XPathResult enum case with an associated value.

  • element(atCSSSelector:) Extension method

    Searches 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

    selector

    CSS selector to search by.

    Return Value

    The first element matching given selector. nil if corresponding XPath does not contain any nodes.