Document
public final class Document: ParentNode
The Document class represents the entire document. Conceptually, it is the
root of the document tree, and provides the primary access to the document’s
data.
-
The
nodeTypeof aDocumentis.document.Declaration
Swift
public static let nodeType: NodeType = .document -
The
nodeNameof aDocumentis#document.Declaration
Swift
public final let nodeName: String = "#document" -
The
nodeValueof aDocumentisnil.Declaration
Swift
public final let nodeValue: String? = nil -
The children of the document will contain the document element and any processing instructions or comments that are siblings of the documnent element.
Declaration
Swift
public final var children: [Node] = [] -
The
attributesdictionary of aDocumentisnil.Declaration
Swift
public final let attributes: [String : String]? = nil
-
This is a convenience attribute that allows direct access to the child node that is the root element of the document.
Declaration
Swift
public final var documentElement: Element? -
Creates a new
Documentnode.Declaration
Swift
public init()
-
Traverses the document tree, collecting
Elementnodes with the specified tag name from anywhere in the document.Declaration
Swift
public final func elements(withTagName name: String) -> [Element]Parameters
nameCollect elements with this tag name.
Return Value
An array of elements with the specified tag name.
-
Traverses the document tree, collecting
Elementnodes that satisfy the given predicate from anywhere in the document.Declaration
Parameters
predicateA closure that takes an element as its argument and returns a Boolean value indicating whether the element should be included in the returned array.
Return Value
An array of the elements that
predicateallowed.
View on GitHub
Install in Dash
Document Class Reference