first
Get the first matched element.
func first() -> Element?
<return>
Get the first matched element.
func first() -> Element?
<return>
import SwiftSoup
class Elements
class Element
init()
base init
init(_ a: Array<Element>)
Initialized with an array
init(_ a: OrderedSet<Element>)
Initialized with an order set
var count: Int { get }
The number of Element objects in the collection. Equivalent to size()
var endIndex: Int { get }
var startIndex: Int { get }
subscript(position: Int) -> Element { get }
static func == (lhs: Elements, rhs: Elements) -> Bool
func add(_ e: Element)
func add(_ index: Int, _ element: Element)
@discardableResult func addClass(_ className: String) throws -> Elements
Add the class name to every matched element’s {@code class} attribute.
@discardableResult func after(_ html: String) throws -> Elements
@discardableResult func append(_ html: String) throws -> Elements
func array() -> Array<Element>
Returns all elements
func attr(_ attributeKey: String) throws -> String
Get an attribute value from the first matched element that has the attribute.
@discardableResult func attr(_ attributeKey: String, _ attributeValue: String) throws -> Elements
@discardableResult func before(_ html: String) throws -> Elements
func copy(with zone: NSZone? = nil) -> Any
func eachText() throws -> Array<String>
Get the text content of each of the matched elements. If an element has no text, then it is not included in the result.
@discardableResult func empty() -> Elements
func eq(_ index: Int) -> Elements
func forms() -> Array<FormElement>
func get(_ i: Int) -> Element
Return element at index
func hasAttr(_ attributeKey: String) -> Bool
Checks if any of the matched elements have this attribute set.
func hasClass(_ className: String) -> Bool
Determine if any of the matched elements have this class name set in their {@code class} attribute.
func hasText() -> Bool
Check if an element has text
func html() throws -> String
@discardableResult func html(_ html: String) throws -> Elements
func iS(_ query: String) throws -> Bool
func isEmpty() -> Bool
Check if no element stored
func last() -> Element?
Get the last matched element.
func makeIterator() -> ElementsIterator
Returns an iterator over the elements of this sequence.
func not(_ query: String) throws -> Elements
func outerHtml() throws -> String
func parents() -> Elements
@discardableResult func prepend(_ html: String) throws -> Elements
@discardableResult func remove() throws -> Elements
@discardableResult func removeAttr(_ attributeKey: String) throws -> Elements
@discardableResult func removeClass(_ className: String) throws -> Elements
Remove the class name from every matched element’s {@code class} attribute, if present.
func select(_ query: String) throws -> Elements
func size() -> Int
Count
@discardableResult func tagName(_ tagName: String) throws -> Elements
func text(trimAndNormaliseWhitespace: Bool = true) throws -> String
func toString() throws -> String
@discardableResult func toggleClass(_ className: String) throws -> Elements
Toggle the class name on every matched element’s {@code class} attribute.
@discardableResult func traverse(_ nodeVisitor: NodeVisitor) throws -> Elements
@discardableResult func unwrap() throws -> Elements
func val() throws -> String
@discardableResult func val(_ value: String) throws -> Elements
@discardableResult func wrap(_ html: String) throws -> Elements
Wrap the supplied HTML around each matched elements. For example, with HTML {@code
This is SwiftSoup
},doc.select(“b”).wrap(”<i></i>”);
becomes {@code This is SwiftSoup
}