Node
public protocol Node: Searchable, CustomStringConvertible
Instances of conforming types represent a document object model node that can be searched by an XPath or CSS selector and also provide the node’s underlying data in a number of ways.
In the HTML/XML DOM (Document Object Model), everything is a node:
The document itself is a document node;
All HTML/XML elements are element nodes;
All HTML/XML attributes are attribute nodes;
Text inside HTML elements are text nodes;
Comments are comment nodes.
-
Text content of the node. May be
nilif no content is available.Declaration
Swift
var text: String? -
HTML content of the node. May be
nilif no content is available.Declaration
Swift
var html: String? -
XML content of the node. May be
nilif no content is available.Declaration
Swift
var xml: String? -
HTML content of the node without outermost tags. Only available if the
htmlproperty is notnil.Declaration
Swift
var innerHTML: String? -
Value of the attribute
class
of the node. This property isnilif the node does not have aclass
attributeDeclaration
Swift
var className: String? -
Name of the corresponding tag for this node.
Note
Setting this property tonildoes not make any change.Declaration
Swift
var tagName: String? -
Content of the node. May be
nilif no content is available.Declaration
Swift
var content: String?
-
descriptionExtension methodA textual representation of this instance.
Instead of accessing this property directly, convert an instance of any type to a string by using the
String(describing:)initializer. For example:struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)"The conversion of
pto a string in the assignment tosuses thePointtype’sdescriptionproperty.Declaration
Swift
public var description: String
Node Protocol Reference