Document class

Represents an HTML document.

The document is the root of the DOM tree and provides methods for creating and querying elements.

Inheritance

Constructors

Document([String? documentURI])
Creates a new document with an optional documentURI.

Properties

attributes List<Attribute>
The list of attributes on this node (only meaningful for elements).
getter/setter pairinherited
baseURI String
The base URI for resolving relative URLs in this document.
no setter
body Element?
The <body> element of the document.
getter/setter pair
childNodes List<Node>
The list of child nodes.
getter/setter pairinherited
children List<Element>
The element children of this node.
no setterinherited
documentElement Element?
The root element of the document (typically <html>).
getter/setter pair
documentURI String?
The URI of the document (if provided during parsing).
final
firstChild Node?
no setterinherited
firstElementChild Element?
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
The <head> element of the document.
getter/setter pair
innerHTML String
getter/setter pairoverride
lastChild Node?
no setterinherited
lastElementChild Element?
no setterinherited
localName String?
The local name of the element (lowercase tag name without namespace).
getter/setter pairinherited
nextSibling Node?
The next sibling node, or null if this is the last child.
getter/setter pairinherited
nodeName String?
The name of the node (tag name for elements, special names for others).
getter/setter pairinherited-setteroverride-getter
nodeType int
The type of this node (see NodeType constants).
no setteroverride
parentNode Node?
The parent node of this node, or null if this is the root.
getter/setter pairinherited
previousSibling Node?
The previous sibling node, or null if this is the first child.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
styleSheets List
The list of stylesheets in the document.
final
textContent String
getter/setter pairoverride
title String
The document title (from the <title> element).
getter/setter pair

Methods

appendChild(Node child) Node
Appends a child node to this node's children.
inherited
createDocumentFragment() DocumentFragment
Creates a new document fragment.
createElement(String tag) Element
Creates a new element with the specified tag name.
createTextNode(String text) TextNode
Creates a new text node with the specified text content.
getElementById(String id) Element?
Returns the element with the specified id, or null if not found.
getElementsByTagName(String tag) List<Element>
Returns all descendant elements with the specified tag name.
inherited
insertBefore(Node newNode, Node? referenceNode) Node
Inserts newNode before referenceNode in this node's children.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
querySelector(String selectors) Element?
Returns the first element within the document that matches the specified selector.
querySelectorAll(String selectors) List<Element>
Returns all elements within the document that match the specified selector.
remove() Node
Removes this node from its parent.
inherited
removeChild(Node child) Node
Removes child from this node's children.
inherited
replaceChild(Node newNode, Node oldNode) Node
Replaces oldNode with newNode in this node's children.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited